1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Original from https://github.com/ps3dev/ps3toolchain
# Updated for binutils 2.40 by Darjan Krijan [https://disc-kuraudo.eu]
diff '--color=auto' -urN a/ld/emulparams/elf32_spu.sh b/ld/emulparams/elf32_spu.sh
--- a/ld/emulparams/elf32_spu.sh 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/emulparams/elf32_spu.sh 2023-01-04 22:15:19.310575828 +0100
@@ -6,6 +6,8 @@
ARCH=spu
MACHINE=
ALIGNMENT=16
+GENERATE_PIE_SCRIPT=yes
+GENERATE_COMBRELOC_SCRIPT=yes
TEXT_START_ADDR=0
INITIAL_READONLY_SECTIONS='.interrupt : { KEEP(*(.interrupt)) }'
if test -z "${CREATE_SHLIB}"; then
diff '--color=auto' -urN a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em
--- a/ld/emultempl/spuelf.em 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/emultempl/spuelf.em 2023-01-04 22:17:32.998687355 +0100
@@ -258,6 +258,14 @@
return total;
}
+static void
+spu_before_parse (void)
+{
+ gld${EMULATION_NAME}_before_parse ();
+
+ config.has_pie = `if test -n "$GENERATE_PIE_SCRIPT" ; then echo true ; else echo false ; fi`;
+}
+
/* Go find if we need to do anything special for overlays. */
static void
@@ -851,5 +859,6 @@
LDEMUL_AFTER_OPEN=spu_after_open
LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
+LDEMUL_BEFORE_PARSE=spu_before_parse
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
diff '--color=auto' -urN a/ld/ld.h b/ld/ld.h
--- a/ld/ld.h 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/ld.h 2023-01-04 22:24:33.832738444 +0100
@@ -229,6 +229,9 @@
parameter. */
bool has_shared;
+ /* If TRUE, -pie is supported. */
+ bool has_pie;
+
/* If TRUE, build constructors. */
bool build_constructors;
diff '--color=auto' -urN a/ld/ldmain.c b/ld/ldmain.c
--- a/ld/ldmain.c 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/ldmain.c 2023-01-04 22:16:46.319346843 +0100
@@ -315,6 +315,7 @@
config.make_executable = true;
config.magic_demand_paged = true;
config.text_read_only = true;
+ config.has_pie = false;
config.print_map_discarded = true;
link_info.disable_target_specific_optimizations = -1;
diff '--color=auto' -urN a/ld/lexsup.c b/ld/lexsup.c
--- a/ld/lexsup.c 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/lexsup.c 2023-01-04 22:17:19.218882047 +0100
@@ -1286,6 +1286,8 @@
if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
}
+ else if (config.has_pie)
+ link_info.type = type_pie;
else
einfo (_("%F%P: -shared not supported\n"));
break;
|