[llvm] [llvm-objcopy][COFF] Update .symidx values after stripping (PR #153322)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 01:11:53 PDT 2025


================
@@ -0,0 +1,225 @@
+## Bail out if a section consisting of symidx is invalid.
+## It includes both: an unexpected format for patching section data and
+## updating the checksum, as well as data validity.
+## Essentially, the expected format is a definitive symbol with a zero offset
+## linked to the section. Valid data consists of a sequence of symbol indices
+## that remain in the symbol table even after stripping.
+
+## In this case, the symbol .gfids$y is not present at all.
+
+# RUN: yaml2obj %s --docnum=1 -o %t1.in.o
+# RUN: not llvm-objcopy --strip-debug %t1.in.o %t1.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-NOSYM -DFILE=%t1.out.o
+
+# ERROR-NOSYM: error: '[[FILE]]': section '.gfids$y' does not have the corresponding symbol or the symbol has unexpected format
+
+--- !COFF
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [  ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    Alignment:       4
+    SectionData:     488D0500000000488D0D00000000488D0500000000488D0500000000
----------------
jh7370 wrote:

There seems to be a lot of stuff in this YAML that isn't necessary for the test. For example, I'm assuming that the content of this SectionData is irrelevant and could be removed. It would be better to have the minimum we need to exhibit the test behaviour we want, so that it's clearer to future readers of the test what is actually important.

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


More information about the llvm-commits mailing list