[llvm] [llvm-objcopy] Add --change-section-address (PR #98664)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 02:45:29 PDT 2024
================
@@ -0,0 +1,211 @@
+# Tests behavior of --change-section-address option
+# --------------------------------------------------
+# yaml2obj generates an object file %ti that looks like this:
+#
+# llvm-readelf --section-headers %ti
+# Section Headers:
+# [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+# [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
+# [ 1] .text1 PROGBITS 0000000000000100 000040 000100 00 0 0 0
+# [ 2] .text2 PROGBITS 0000000000000200 000140 000100 00 0 0 0
+# [ 3] .anotherone PROGBITS 0000000000000300 000240 000100 00 0 0 0
+# [ 4] =a-b+c++d PROGBITS 0000000000000400 000340 000100 00 0 0 0
+# [ 5] .strtab STRTAB 0000000000000000 000440 000001 00 0 0 1
+# [ 6] .shstrtab STRTAB 0000000000000000 000441 000037 00 0 0 1
+#
+# Various changes are applied to this file using llvm-objcopy --change-section-address and
+# results are checked for expected address values, or errors.
+#
+
+# RUN: yaml2obj -DTYPE=REL %s -o %ti
+
+# Basic check that the option processes wildcards and changes the address as expected
+# RUN: llvm-objcopy --change-section-address *+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-ADD-ALL
+
+# Check --change-section-address alias --adjust-section-vma
----------------
jh7370 wrote:
It's similar, but the difference is that if there is anything impacted by the different name, that isn't covered by the FileCheck line, the cmp will catch it. For example, imagine an option that was supposed to be an alias for --strip-debug, you might check that there are no section names matching "debug" in the output, but if you accidentally aliased --strip-all instead, you'd have this behaviour and more.
https://github.com/llvm/llvm-project/pull/98664
More information about the llvm-commits
mailing list