[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
----------------
jh7370 wrote:

By default, FileCheck does a search for pattern matches throughout the whole output, then when it finds it, looks for the next check pattern in the remainder of the output and so on. The next pattern could be later on the same line as the first match, or several lines later. Quite often, as is the case here, this isn't exactly what you want: you want the match to be on the next line. You can do this by adding `-NEXT` as a suffix to the check prefix to all lines after the first (i.e. `WARN:` for the first check and `WARN-NEXT:` for all subsequent ones).

For more information, it's worth reading https://llvm.org/docs/CommandGuide/FileCheck.html. There are several other suffixes that exist, which can be quite useful to be aware of.

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


More information about the llvm-commits mailing list