File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ inline const char helpmsg[] = R"(
141
141
--sort-common Ignored
142
142
--sort-section Ignored
143
143
--spare-dynamic-tags NUMBER Reserve give number of tags in .dynamic section
144
+ --spare-program-headers NUMBER
145
+ Reserve give number of slots in the program header
144
146
--start-lib Give following object files in-archive-file semantics
145
147
--end-lib End the effect of --start-lib
146
148
--stats Print input statistics
@@ -606,6 +608,9 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
606
608
ctx.arg .shared = true ;
607
609
} else if (read_arg (" spare-dynamic-tags" )) {
608
610
ctx.arg .spare_dynamic_tags = parse_number (ctx, " spare-dynamic-tags" , arg);
611
+ } else if (read_arg (" spare-program-headers" )) {
612
+ ctx.arg .spare_program_headers
613
+ = parse_number (ctx, " spare-program-headers" , arg);
609
614
} else if (read_flag (" start-lib" )) {
610
615
remaining.push_back (" --start-lib" );
611
616
} else if (read_flag (" start-stop" )) {
Original file line number Diff line number Diff line change @@ -1700,6 +1700,7 @@ struct Context {
1700
1700
bool z_text = false ;
1701
1701
i64 filler = -1 ;
1702
1702
i64 spare_dynamic_tags = 5 ;
1703
+ i64 spare_program_headers = 0 ;
1703
1704
i64 thread_count = 0 ;
1704
1705
i64 z_stack_size = 0 ;
1705
1706
u64 shuffle_sections_seed;
Original file line number Diff line number Diff line change @@ -352,6 +352,7 @@ static std::vector<ElfPhdr<E>> create_phdr(Context<E> &ctx) {
352
352
}
353
353
}
354
354
355
+ vec.resize (vec.size () + ctx.arg .spare_program_headers );
355
356
return vec;
356
357
}
357
358
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ . $( dirname $0 ) /common.inc
3
+
4
+ cat << EOF | $CC -o $t /a.o -c -xc -
5
+ #include <stdio.h>
6
+ int main() {
7
+ printf("Hello world\n");
8
+ }
9
+ EOF
10
+
11
+ $CC -B. -o $t /exe1 $t /a.o
12
+ $QEMU $t /exe1 | grep -q ' Hello world'
13
+ [ " $( readelf -Wl $t /exe1 | grep NULL | wc -l) " -eq 0 ]
14
+
15
+ $CC -B. -o $t /exe2 $t /a.o -Wl,--spare-program-headers=0
16
+ $QEMU $t /exe2 | grep -q ' Hello world'
17
+ [ " $( readelf -Wl $t /exe2 | grep NULL | wc -l) " -eq 0 ]
18
+
19
+ $CC -B. -o $t /exe3 $t /a.o -Wl,--spare-program-headers=1
20
+ $QEMU $t /exe3 | grep -q ' Hello world'
21
+ [ " $( readelf -Wl $t /exe3 | grep NULL | wc -l) " -eq 1 ]
22
+
23
+ $CC -B. -o $t /exe4 $t /a.o -Wl,--spare-program-headers=5
24
+ $QEMU $t /exe4 | grep -q ' Hello world'
25
+ [ " $( readelf -Wl $t /exe4 | grep NULL | wc -l) " -eq 5 ]
You can’t perform that action at this time.
0 commit comments