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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 01:02:30 PST 2025


================
@@ -474,14 +474,10 @@ Sections:
 # 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:  NEEDED 0x0000000000000010
+# WARN:  NEEDED
----------------
jh7370 wrote:

You'll want to add `{{$}}` to the end of this line (after one or more spaces).

By default, FileCheck looks for substrings on lines and ignores other text on the line, so this case would match `NEEDED some-complete-nonsense` in the output, for example. There are ways of avoiding that, with command-line options but in this case it would have a slightly negative impact on the test, I believe, so instead, we can use a FileCheck regular expression (delineated by the `{{` and `}}`) to match the end of line (which is what the `$` means).

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


More information about the llvm-commits mailing list