[llvm] [llvm-objdump] Print out xcoff load section of xcoff object file with option private-headers (PR #121226)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 10:23:43 PST 2025
================
@@ -262,6 +264,45 @@ void XCOFFDumper::printAuxiliaryHeader(
AuxSize, *AuxHeader);
}
+void XCOFFDumper::printLoaderSectionHeader() {
+ Expected<uintptr_t> LoaderSectionAddrOrError =
+ Obj.getSectionFileOffsetToRawData(XCOFF::STYP_LOADER);
+ if (!LoaderSectionAddrOrError) {
+ reportUniqueWarning(LoaderSectionAddrOrError.takeError());
+ return;
+ }
+ uintptr_t LoaderSectionAddr = LoaderSectionAddrOrError.get();
+
+ if (LoaderSectionAddr == 0)
+ return;
+
+ auto PrintLoadSecHeaderCommon = [&](const auto *LDHeader) {
+ printNumber("Version:", LDHeader->Version);
+ printNumber("NumberOfSymbolEntries:", LDHeader->NumberOfSymTabEnt);
+ printNumber("NumberOfRelocationEntries:", LDHeader->NumberOfRelTabEnt);
+ printNumber("LengthOfImportFileIDStringTable:",
+ LDHeader->LengthOfImpidStrTbl);
+ printNumber("NumberOfImportFileIDs:", LDHeader->NumberOfImpid);
+ printHex("OffsetToImportFileIDs:", LDHeader->OffsetToImpid);
+ printNumber("LengthOfStringTable:", LDHeader->LengthOfStrTbl);
+ printHex("OffsetToStringTable:", LDHeader->OffsetToStrTbl);
+ };
+
+ Width = 35;
+ outs() << "\n---Loader Section Header:\n";
+ if (Obj.is64Bit()) {
+ const LoaderSectionHeader64 *LoaderSec64 =
+ reinterpret_cast<const LoaderSectionHeader64 *>(LoaderSectionAddr);
----------------
diggerlin wrote:
If I understand your question correctly. I wrote a following test case and run , it do not crash. it looks the PowerPC do not need to be alignment on the memory in when reading the data.
```
bash> cat test.cpp
unsigned int var =10;
int main() {
char *cvar = reinterpret_cast<char *>(&var)+1;
int *us = reinterpret_cast<int *>(cvar);
(*us)++;
return *us;
}
```
https://github.com/llvm/llvm-project/pull/121226
More information about the llvm-commits
mailing list