[llvm] [llvm-objcopy] --change-section-lma: skip segments with no assigned address (PR #218414)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 01:52:00 PDT 2026


================
@@ -0,0 +1,38 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy --change-section-lma *-0x30 %t %t2
+# RUN: llvm-readelf --program-headers %t2 | FileCheck %s
+
+# Regression test: a segment with a nonzero MemSize but no assigned
+# VAddr/PAddr (e.g. PT_RISCV_ATTRIBUTES) must not participate in
+# --change-section-lma; previously this caused a spurious underflow
+# error when shifting other segments downward.
+#
+# This is a separate file (rather than an addition to
+# change-section-lma.test) because that file's first LOAD segment's
+# size is implicitly derived from the total program header table
+# size, making it fragile to extend with additional entries.
----------------
jh7370 wrote:

1. Comments in new llvm-objcopy tests should use `##` not `#` to help distinguish them from lit directives like RUN and FileCheck commands.
2. yaml2obj has the ability to use --docnum to distinguish multiple YAML documents in the same file. However, you'll also need to tweak the YAML (I believe you need `--- !ELF` for example.
3. Why did you specifically include "Regression test" in the test comments? We generally don't include references to "previously" etc, because that information becomes stale.
4. Test descriptions usually go before the test RUN lines.

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


More information about the llvm-commits mailing list