[llvm] [llvm-objcopy] Fix prints wrong path when section output path doesn't exist (PR #125345)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 1 13:01:52 PST 2025


================
@@ -0,0 +1,37 @@
+## Show that llvm-objcopy report that section file path is not exists.
+
+# RUN: yaml2obj %s -o %t
+
+# RUN: not llvm-objcopy --dump-section .text=not_exists/text-section %t 2>&1 \
+# RUN:   | FileCheck %s -DINPUT=%t --check-prefix=NO-SUCH-PATH
+# Don't check the OS-dependent message "No such file or directory".
+# NO-SUCH-PATH: error: 'not_exists/text-section':
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000001000
+    Content:         "DEADBEEF"
+  - Name:            .foo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE ]
+    Content:         "CAFE"
+  - Name:            .empty
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+  - Name:            .bar
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE ]
+ProgramHeaders:
----------------
MaskRay wrote:

Delete unused `ProgramHeaders` and trailing blank lines

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


More information about the llvm-commits mailing list