[PATCH] D134528: [llvm-readobj][COFF] Print forwarder export symbols correctly
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 01:07:02 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe5582981a74: [llvm-readobj][COFF] Print forwarder export symbols correctly (authored by alvinhochun, committed by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134528/new/
https://reviews.llvm.org/D134528
Files:
llvm/test/tools/llvm-readobj/COFF/exports-forwarder.yaml
llvm/tools/llvm-readobj/COFFDumper.cpp
Index: llvm/tools/llvm-readobj/COFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/COFFDumper.cpp
+++ llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -1789,18 +1789,29 @@
DictScope Export(W, "Export");
StringRef Name;
- uint32_t Ordinal, RVA;
+ uint32_t Ordinal;
+ bool IsForwarder;
if (Error E = Exp.getSymbolName(Name))
reportError(std::move(E), Obj->getFileName());
if (Error E = Exp.getOrdinal(Ordinal))
reportError(std::move(E), Obj->getFileName());
- if (Error E = Exp.getExportRVA(RVA))
+ if (Error E = Exp.isForwarder(IsForwarder))
reportError(std::move(E), Obj->getFileName());
W.printNumber("Ordinal", Ordinal);
W.printString("Name", Name);
- W.printHex("RVA", RVA);
+ StringRef ForwardTo;
+ if (IsForwarder) {
+ if (Error E = Exp.getForwardTo(ForwardTo))
+ reportError(std::move(E), Obj->getFileName());
+ W.printString("ForwardedTo", ForwardTo);
+ } else {
+ uint32_t RVA;
+ if (Error E = Exp.getExportRVA(RVA))
+ reportError(std::move(E), Obj->getFileName());
+ W.printHex("RVA", RVA);
+ }
}
}
Index: llvm/test/tools/llvm-readobj/COFF/exports-forwarder.yaml
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-readobj/COFF/exports-forwarder.yaml
@@ -0,0 +1,52 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj --coff-exports %t | FileCheck %s
+
+# CHECK: Export {
+# CHECK-NEXT: Ordinal: 1
+# CHECK-NEXT: Name: LoadLibrary
+# CHECK-NEXT: ForwardedTo: kernel32.LoadLibrary
+# CHECK-NEXT: }
+
+# Test file generated with:
+# clang -O2 --target=x86_64-windows-msvc test.c -nostdlib -c -o test.obj
+# lld-link -dll -out:test.dll -entry:entry -export:LoadLibrary=kernel32.LoadLibrary test.obj
+# test.c:
+# void entry(void) {}
+
+--- !COFF
+OptionalHeader:
+ AddressOfEntryPoint: 4096
+ ImageBase: 6442450944
+ SectionAlignment: 4096
+ FileAlignment: 512
+ MajorOperatingSystemVersion: 6
+ MinorOperatingSystemVersion: 0
+ MajorImageVersion: 0
+ MinorImageVersion: 0
+ MajorSubsystemVersion: 6
+ MinorSubsystemVersion: 0
+ Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI
+ DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT ]
+ SizeOfStackReserve: 1048576
+ SizeOfStackCommit: 4096
+ SizeOfHeapReserve: 1048576
+ SizeOfHeapCommit: 4096
+ ExportTable:
+ RelativeVirtualAddress: 8192
+ Size: 110
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ VirtualAddress: 4096
+ VirtualSize: 1
+ SectionData: C3
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ VirtualAddress: 8192
+ VirtualSize: 110
+ SectionData: 0000000000000000000000002820000001000000010000000100000043200000472000004B2000006578706F72742D666F727761726465722E632E746D702E646C6C00592000004D20000000004C6F61644C696272617279006B65726E656C33322E4C6F61644C69627261727900
+symbols: []
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134528.462835.patch
Type: text/x-patch
Size: 3373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220926/4057baa4/attachment.bin>
More information about the llvm-commits
mailing list