[PATCH] D70475: [llvm-objcopy][MachO] Fix symbol order in the symbol table
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 09:35:27 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG242002770ba0: [llvm-objcopy][MachO] Fix symbol order in the symbol table (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70475/new/
https://reviews.llvm.org/D70475
Files:
llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all.yaml
llvm/test/tools/llvm-objcopy/MachO/strip-all.test
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
Index: llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -64,9 +64,11 @@
assert(std::is_sorted(O.SymTable.Symbols.begin(), O.SymTable.Symbols.end(),
[](const std::unique_ptr<SymbolEntry> &A,
const std::unique_ptr<SymbolEntry> &B) {
- return (A->isLocalSymbol() && !B->isLocalSymbol()) ||
- (!A->isUndefinedSymbol() &&
- B->isUndefinedSymbol());
+ bool AL = A->isLocalSymbol(), BL = B->isLocalSymbol();
+ if (AL != BL)
+ return AL;
+ return !AL && !A->isUndefinedSymbol() &&
+ B->isUndefinedSymbol();
}) &&
"Symbols are not sorted by their types.");
Index: llvm/test/tools/llvm-objcopy/MachO/strip-all.test
===================================================================
--- llvm/test/tools/llvm-objcopy/MachO/strip-all.test
+++ llvm/test/tools/llvm-objcopy/MachO/strip-all.test
@@ -3,6 +3,10 @@
# RUN: yaml2obj %p/Inputs/strip-all.yaml > %t.exec
# RUN: yaml2obj %p/Inputs/strip-all-with-dwarf.yaml > %t.dwarf
+## Check that the symbol list satisfies the order: local / defined external /
+## undefined external, otherwise llvm-objcopy will fail.
+# RUN: llvm-objcopy %t.exec /dev/null
+
# RUN: llvm-objcopy --strip-all %t.exec %t.exec.stripped
# RUN: llvm-readobj --sections --relocations --symbols %t.exec.stripped \
# RUN: | FileCheck --check-prefixes=COMMON,EXEC %s
Index: llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all.yaml
===================================================================
--- llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all.yaml
+++ llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all.yaml
@@ -262,11 +262,13 @@
n_sect: 3
n_desc: 0
n_value: 4294971392
+ ## A local undefined SymDebugTable entry followed by
- n_strx: 175
n_type: 0x20
n_sect: 0
n_desc: 0
n_value: 0
+ ## a defined SymDebugTable entry.
- n_strx: 1
n_type: 0x64
n_sect: 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70475.230471.patch
Type: text/x-patch
Size: 2471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191121/981ceb26/attachment.bin>
More information about the llvm-commits
mailing list