[llvm] [objcopy][coff] Place section name first in strtab (PR #145266)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 23 04:46:56 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
----------------
HaohaiWen wrote:
The multiKeySort in StringTableBuilder compare char of string from end to begin, and the larger the letter, the earlier it appears in the sort order. In this test, symbol_zzz should be place in front of .debug_str without this code. see https://github.com/llvm/llvm-project/commit/2401b47be0bfdef0bf14da9b13a17edbb43642ff
https://github.com/llvm/llvm-project/blob/7e77aaebfbfce2861c562fe631649ec472ea233b/llvm/lib/MC/StringTableBuilder.cpp#L96
https://github.com/llvm/llvm-project/pull/145266
More information about the llvm-commits
mailing list