xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativePublicSymbol.cpp (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1 //===- NativePublicSymbol.cpp - info about public symbols -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/Native/NativePublicSymbol.h"
10 
11 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
12 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
18 
19 NativePublicSymbol::NativePublicSymbol(NativeSession &Session, SymIndexId Id,
20                                        const codeview::PublicSym32 &Sym)
21     : NativeRawSymbol(Session, PDB_SymType::Data, Id), Sym(Sym) {}
22 
23 NativePublicSymbol::~NativePublicSymbol() {}
24 
25 void NativePublicSymbol::dump(raw_ostream &OS, int Indent,
26                               PdbSymbolIdField ShowIdFields,
27                               PdbSymbolIdField RecurseIdFields) const {
28   NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
29   dumpSymbolField(OS, "name", getName(), Indent);
30   dumpSymbolField(OS, "offset", getAddressOffset(), Indent);
31   dumpSymbolField(OS, "section", getAddressSection(), Indent);
32 }
33 
34 uint32_t NativePublicSymbol::getAddressOffset() const { return Sym.Offset; }
35 
36 uint32_t NativePublicSymbol::getAddressSection() const { return Sym.Segment; }
37 
38 std::string NativePublicSymbol::getName() const {
39   return std::string(Sym.Name);
40 }
41 
42 PDB_SymType NativePublicSymbol::getSymTag() const {
43   return PDB_SymType::PublicSymbol;
44 }
45 
46 uint32_t NativePublicSymbol::getRelativeVirtualAddress() const {
47   return Session.getRVAFromSectOffset(Sym.Segment, Sym.Offset);
48 }
49 
50 uint64_t NativePublicSymbol::getVirtualAddress() const {
51   return Session.getVAFromSectOffset(Sym.Segment, Sym.Offset);
52 }
53