[llvm] [llvm-objcopy] Add --change-section-address (PR #98664)
Eleanor Bonnici via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 07:24:44 PDT 2024
================
@@ -0,0 +1,120 @@
+# RUN: yaml2obj --docnum=1 %s -o %ti
+
+# RUN: llvm-objcopy --adjust-section-vma *+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-ADD-ALL
+
+# RUN: llvm-objcopy --change-section-address *+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-ADD-ALL
+
+# RUN: llvm-objcopy --change-section-address .anotherone-0x30 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-SUB-SECTION
+
+# RUN: llvm-objcopy --change-section-address .text*+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-ADD-PATTERN
+
+# RUN: llvm-objcopy --change-section-address .text*=0x10 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-SET-PATTERN
+
+# RUN: llvm-objcopy --change-section-address .anotherone-0x30 --change-section-address .anotherone+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-USE-LAST
+
+# RUN: llvm-objcopy --change-section-address .anotherone=0x455 --change-section-address *+0x20 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-NOTSUPERSET-SET
+
+# RUN: llvm-objcopy --change-section-address *+0x20 --change-section-address .anotherone=0x455 %ti %to
+# RUN: llvm-readelf --section-headers %to | FileCheck %s --check-prefix=CHECK-SUPERSET-SET
+
+# CHECK-ADD-ALL: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+# CHECK-ADD-ALL: .text1
+# CHECK-ADD-ALL-SAME: 0000000000000120
----------------
eleanor-arm wrote:
The last point shouldn't be a real issue. There's no number that big on the same line after address.
As for the error messages this is the difference
1. Regex
```
change-section-address.test:51:18: error: CHECK-ADD-ALL: expected string not found in input
# CHECK-ADD-ALL: .text1 {{[A-Z]+}} 1000000000000120
^
<stdin>:4:24: note: scanning from here
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
^
<stdin>:6:7: note: possible intended match here
[ 1] .text1 PROGBITS 0000000000000120 000040 000100 00 0 0 0
^
Input file: <stdin>
Check file: change-section-address.test
-dump-input=help explains the following input dump.
Input was:
<<<<<<
1: There are 7 section headers, starting at offset 0x478:
2:
3: Section Headers:
4: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
check:51'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
5: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
check:51'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6: [ 1] .text1 PROGBITS 0000000000000120 000040 000100 00 0 0 0
check:51'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:51'1 ? possible intended match
```
2. CHECK-SAME
```
change-section-address.test:52:23: error: CHECK-ADD-ALL-SAME: expected string not found in input
# CHECK-ADD-ALL-SAME: 1000000000000120
^
<stdin>:6:13: note: scanning from here
[ 1] .text1 PROGBITS 0000000000000120 000040 000100 00 0 0 0
^
<stdin>:6:23: note: possible intended match here
[ 1] .text1 PROGBITS 0000000000000120 000040 000100 00 0 0 0
^
Input file: <stdin>
Check file: change-section-address.test
-dump-input=help explains the following input dump.
Input was:
<<<<<<
1: There are 7 section headers, starting at offset 0x478:
2:
3: Section Headers:
4: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
5: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
6: [ 1] .text1 PROGBITS 0000000000000120 000040 000100 00 0 0 0
same:52'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
same:52'1 ? possible intended match
```
The second points closer where the mismatch is (in the address value in this case, not the section name).
https://github.com/llvm/llvm-project/pull/98664
More information about the llvm-commits
mailing list