[llvm] [llvm-objcopy][COFF] Support --rename-section (PR #210573)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 00:11:06 PDT 2026
================
@@ -0,0 +1,101 @@
+# RUN: yaml2obj %s -o %t
+
+## Basic rename: section header, contents, alignment, and section symbol.
+# RUN: llvm-objcopy --rename-section=.foo=.bar %t %t2
+# RUN: llvm-readobj --sections --section-data --symbols %t2 | FileCheck %s
+
+## Bad format / multiple renames of the same source (CLI, format-agnostic).
+# RUN: not llvm-objcopy --rename-section=.foo.bar --rename-section=.foo=.other %t %t2 2>&1 | \
+# RUN: FileCheck %s --check-prefix=BAD-FORMAT
+# RUN: not llvm-objcopy --rename-section=.foo=.bar --rename-section=.foo=.other %t %t2 2>&1 | \
+# RUN: FileCheck %s --check-prefix=MULTIPLE-RENAMES
+
+## Section renames do not chain in one invocation.
+# RUN: llvm-objcopy --rename-section=.foo=.bar --rename-section=.bar=.baz %t %t3
+# RUN: cmp %t2 %t3
+
+## Renaming a nonexistent section is a silent no-op.
+# RUN: llvm-objcopy --rename-section=.missing=.other %t %t4
+# RUN: cmp %t %t4
+
+## Empty new name is allowed (matches LLVM ELF and COFF --add-section).
+# RUN: llvm-objcopy --rename-section=.foo= %t %t5
+# RUN: llvm-readobj --sections %t5 | FileCheck %s --check-prefix=EMPTY-NAME
+
+## PE executable smoke: rename a section header when there are no symbols.
----------------
jh7370 wrote:
I'm not sure I understand the significance of this specific test case. Is it that it's a PE file or that there are no symbols? If both, why is it important to test both at the same time? What does the presence (or lack thereof) of symbols impact?
https://github.com/llvm/llvm-project/pull/210573
More information about the llvm-commits
mailing list