aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/ObjectYAML
diff options
context:
space:
mode:
authorDaniel Rodríguez Troitiño <danielrodriguez@fb.com>2022-10-03 17:46:42 -0700
committerDaniel Rodríguez Troitiño <danielrodriguez@fb.com>2022-10-04 09:17:58 -0700
commit57bd11f047d040fb52520a0ae2bc74542099a162 (patch)
treecd3733027f1cbecdc2d487c79d643029d6fe4ef5 /llvm/test/ObjectYAML
parent54a4e9685d0110a28a88a40cf9e8d05a4ecdd631 (diff)
downloadllvm-57bd11f047d040fb52520a0ae2bc74542099a162.zip
llvm-57bd11f047d040fb52520a0ae2bc74542099a162.tar.gz
llvm-57bd11f047d040fb52520a0ae2bc74542099a162.tar.bz2
[ObjectYAML][MachO] Encode export trie address as ULEB128, not as SLEB128
The `dumpExportEntry` was dumping everything using signed LEB128, but the format seems to use unsigned LEB128. This can be cross-checked with the implementation in MachOObjectFile.cpp, the implementation in LLD's ExportTrie.cpp, and the implementation in macho2yaml.cpp, which all use ULEB128 functions.. The difference is only apparent when encoding some values with specific bit patterns (bit active in the 7th, 14th, ... bits of the binary). The encoding was not always creating problems in the resulting binaries because if the extra byte was part of the padding, the result of decoding it as ULEB128 is the same as decoding as SLEB128, however, the code of MachOObjectFile.cpp (used by llvm-objdump) checks the buffer decoding position against the reported length, which triggered an error. Modified a test that used an address with this pattern (0x3FA0, the 14th bit is active), to show that a round trip still produces the same results, and added a check using llvm-objdump to use their extra checks to verify this implementation. Reviewed By: pete Differential Revision: https://reviews.llvm.org/D134563
Diffstat (limited to 'llvm/test/ObjectYAML')
-rw-r--r--llvm/test/ObjectYAML/MachO/export_trie.yaml12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/test/ObjectYAML/MachO/export_trie.yaml b/llvm/test/ObjectYAML/MachO/export_trie.yaml
index 635e507..9c359db 100644
--- a/llvm/test/ObjectYAML/MachO/export_trie.yaml
+++ b/llvm/test/ObjectYAML/MachO/export_trie.yaml
@@ -1,4 +1,6 @@
-# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+# RUN: yaml2obj %s -o=%t
+# RUN: obj2yaml %t | FileCheck %s
+# RUN: llvm-objdump --macho --exports-trie %t | FileCheck %s --check-prefix=OBJDUMP-VERIFY
--- !mach-o
FileHeader:
@@ -167,7 +169,7 @@ LinkEditData:
NodeOffset: 37
Name: main
Flags: 0x0000000000000000
- Address: 0x0000000000001160
+ Address: 0x0000000000003FA0
Other: 0x0000000000000000
ImportName: ''
...
@@ -188,4 +190,8 @@ LinkEditData:
#CHECK: - TerminalSize: 3
#CHECK: NodeOffset: 37
#CHECK: Name: main
-#CHECK: Address: 0x1160
+#CHECK: Address: 0x3FA0
+
+# OBJDUMP-VERIFY: Exports trie:
+# OBJDUMP-VERIFY: 0x100000000 __mh_execute_header
+# OBJDUMP-VERIFY: 0x100003FA0 _main