[llvm] [llvm-objdump][ELF]Fix crash when reading strings from .dynstr (PR #125679)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 02:08:15 PST 2025


================
@@ -470,3 +470,50 @@ Sections:
        Value: 0x1
      - Tag:   DT_NULL
        Value: 0x0
+
+# RUN: yaml2obj --docnum=5 %s -o %t5
+# RUN: llvm-objdump -p %t5 2>&1 | FileCheck %s --strict-whitespace -DFILE=%t5 --check-prefix=WARN
+
+# WARN: Program Header:
+# WARN:    LOAD off    0x00000000000000b0 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
+# WARN:         filesz 0x0000000000000050 memsz 0x0000000000000050 flags ---
+# WARN: DYNAMIC off    0x00000000000000c0 vaddr 0x000000000000101d paddr 0x000000000000101d align 2**0
+# WARN:         filesz 0x0000000000000040 memsz 0x0000000000000040 flags ---
+# WARN: Dynamic Section:
+# WARN: warning: '[[FILE]]': invalid string table offset
+# WARN:  NEEDED 0x0000000000000011
+# WARN:  STRTAB 0x0000000000001000
+# WARN:  STRSZ  0x0000000000000010
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_EXEC
+  Machine: EM_X86_64
+Sections:
+  - Name:    .dynstr
+    Type:    SHT_STRTAB
+    Address: 0x1000
+    Size:    0x10
+    Content: "004400550066007700"
+  - Name: .dynamic
+    Type: SHT_DYNAMIC
+    Entries:
+     - Tag:   DT_NEEDED
+       Value: 0x11
----------------
jh7370 wrote:

The size is `0x10`, so Value should be `0x10` too, to show that an entry pointing immediately after the table results in an error.

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


More information about the llvm-commits mailing list