[llvm] [llvm-objcopy][ELF] Disable huge section offset (PR #97036)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 01:03:40 PDT 2024


================
@@ -0,0 +1,27 @@
+# RUN: yaml2obj %s --docnum=1 -o %t
+# RUN: not llvm-objcopy -O binary %t %t2 --set-max-huge-section-offset=2000000000 2>&1 | FileCheck %s
+
+# CHECK: writing section .high_addr at huge file offset
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_MIPS
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x1000
+    Content:         "00112233445566778899AABBCCDDEEFF"
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_WRITE ]
+    Address:         0x2000
+    Content:         "112233445566778899AABBCCDDEEFF00"
+  - Name:            .high_addr
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_WRITE ]
+    Address:         0x80001000
+    Content:         "2233445566778899AABBCCDDEEFF0011"
----------------
jh7370 wrote:

Similar comment to above: SHF_WRITE is probably superfluous and the content should only be a single byte. I'd also recommend changing the address to a much lower value (and reduce the option value accordingly), so that if the option failed to take effect, it wouldn't result in a massive file on disk. Furthermore, that way you could enhance this test to do bounds checking: checking that if the section is one closer, no error is emitted.

https://github.com/llvm/llvm-project/pull/97036


More information about the llvm-commits mailing list