[llvm] [XCOFF][OBJECT] get symbol size by calling XCOFF interfaces (PR #67304)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 07:13:58 PDT 2023
================
@@ -761,33 +768,39 @@ struct XCOFFSymbolEntry64 {
uint8_t NumberOfAuxEntries;
};
-class XCOFFSymbolRef {
+class XCOFFSymbolRef : public SymbolRef {
public:
enum { NAME_IN_STR_TBL_MAGIC = 0x0 };
XCOFFSymbolRef(DataRefImpl SymEntDataRef,
const XCOFFObjectFile *OwningObjectPtr)
- : OwningObjectPtr(OwningObjectPtr) {
+ : SymbolRef(SymEntDataRef, OwningObjectPtr) {
assert(OwningObjectPtr && "OwningObjectPtr cannot be nullptr!");
assert(SymEntDataRef.p != 0 &&
"Symbol table entry pointer cannot be nullptr!");
-
- if (OwningObjectPtr->is64Bit())
- Entry64 = reinterpret_cast<const XCOFFSymbolEntry64 *>(SymEntDataRef.p);
- else
- Entry32 = reinterpret_cast<const XCOFFSymbolEntry32 *>(SymEntDataRef.p);
}
- const XCOFFSymbolEntry32 *getSymbol32() { return Entry32; }
- const XCOFFSymbolEntry64 *getSymbol64() { return Entry64; }
+#define Entry32 \
+ reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p)
+#define Entry64 \
+ reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p)
+
+ const XCOFFSymbolEntry32 *getSymbol32() const { return Entry32; }
----------------
diggerlin wrote:
since we do not have many place using Entry32/Entry64, I do think we need macro define here,
we can use reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p) directly.
https://github.com/llvm/llvm-project/pull/67304
More information about the llvm-commits
mailing list