[llvm] [objcopy][coff] Place section name first in strtab (PR #145266)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 25 00:04:55 PDT 2025


================
@@ -0,0 +1,24 @@
+# RUN: yaml2obj %s -o %t
+# RUN: touch %t.sec
+# RUN: llvm-objcopy --add-section=.debug_str=%t.sec %t %t1
+# RUN: llvm-readobj --string-table %t1 | FileCheck %s
+
+# CHECK:      StringTable {
+# CHECK-NEXT:   Length: 26
+# CHECK-NEXT:   [     4] .debug_str
+# CHECK-NEXT:   [     f] symbol_zzz
+# CHECK-NEXT: }
+
+--- !COFF
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+symbols:
+  - Name:            symbol_zzz
----------------
jh7370 wrote:

> aaa is too short (< 8 chars) and can be directly encoded into symbol table.

Please add a comment explaining this as it may not be obvious to the casual reader.

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


More information about the llvm-commits mailing list