From 72e4947f85bd75c7339a5427f30ea7540e37265d Mon Sep 17 00:00:00 2001
From: Simon South <ssouth@simonsouth.com>
Date: Thu, 22 Oct 2015 02:38:57 -0400
Subject: [PATCH 1/4] gcc: Allow the user to build non-PI executables
* CC1_SPEC: Remove non-existent "no-fpic" command-line option; add
"fno-PIC" and "fno-PIE" as options that disable the generation of
position-independent code; use "-fPIC" by default.
* LINK_SPEC: Pass "-shared" to the linker only if it was passed to gcc; output
position-independent executables by default; when linking executables, allow
undefined symbols in shared libraries and export all symbols (to match the
behaviour of "-shared").
---
gcc/gcc/config/arm/haiku.h | 2 +-
gcc/gcc/config/haiku.h | 2 +-
gcc/gcc/config/i386/haiku.h | 2 +-
gcc/gcc/config/i386/haiku64.h | 2 +-
gcc/gcc/config/m68k/haiku.h | 2 +-
gcc/gcc/config/mips/haiku.h | 2 +-
gcc/gcc/config/rs6000/haiku.h | 4 ++--
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/gcc/gcc/config/arm/haiku.h b/gcc/gcc/config/arm/haiku.h
index f0c0d63..f0897fa 100644
a
|
b
|
|
75 | 75 | /* If ELF is the default format, we should not use /lib/elf. */ |
76 | 76 | |
77 | 77 | #undef LINK_SPEC |
78 | | #define LINK_SPEC "%{!o*:-o %b} -m armelf %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}\ |
| 78 | #define LINK_SPEC "%{!o*:-o %b} -m armelf %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} %{nostart:-e 0} %{shared:-shared -e 0} %{!shared: %{!nostart: -no-undefined}}\ |
79 | 79 | %{mbig-endian:-EB} %{mlittle-endian:-EL} -X" |
80 | 80 | |
diff --git a/gcc/gcc/config/haiku.h b/gcc/gcc/config/haiku.h
index bf498ee..7f456b7 100644
a
|
b
|
Boston, MA 02111-1307, USA. */
|
46 | 46 | user explicitly asks for the warnings with -Wmultichar. Note that |
47 | 47 | CC1_SPEC is used for both cc1 and cc1plus. */ |
48 | 48 | #undef CC1_SPEC |
49 | | #define CC1_SPEC "%{!no-fpic:%{!fno-pic:%{!fno-pie:%{!fpie:%{!fPIC:%{!fPIE:-fpic}}}}}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" |
| 49 | #define CC1_SPEC "%{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-fPIC} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" |
50 | 50 | |
51 | 51 | #undef CC1PLUS_SPEC |
52 | 52 | #define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}" |
diff --git a/gcc/gcc/config/i386/haiku.h b/gcc/gcc/config/i386/haiku.h
index 3379e19..fb98940 100644
a
|
b
|
Boston, MA 02111-1307, USA. */
|
53 | 53 | /* If ELF is the default format, we should not use /lib/elf. */ |
54 | 54 | |
55 | 55 | #undef LINK_SPEC |
56 | | #define LINK_SPEC "-m elf_i386_haiku %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}" |
| 56 | #define LINK_SPEC "-m elf_i386_haiku %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} %{nostart:-e 0} %{shared:-shared -e 0} %{!shared: %{!nostart: -no-undefined}}" |
57 | 57 | |
58 | 58 | /* A C statement (sans semicolon) to output to the stdio stream |
59 | 59 | FILE the assembler definition of uninitialized global DECL named |
diff --git a/gcc/gcc/config/i386/haiku64.h b/gcc/gcc/config/i386/haiku64.h
index 41b3319..d1c9b4b 100644
a
|
b
|
Boston, MA 02111-1307, USA. */
|
65 | 65 | |
66 | 66 | #undef LINK_SPEC |
67 | 67 | #define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386_haiku} \ |
68 | | %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}" |
| 68 | %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} %{nostart:-e 0} %{shared:-shared -e 0} %{!shared: %{!nostart: -no-undefined}}" |
69 | 69 | |
70 | 70 | /* A C statement (sans semicolon) to output to the stdio stream |
71 | 71 | FILE the assembler definition of uninitialized global DECL named |
diff --git a/gcc/gcc/config/m68k/haiku.h b/gcc/gcc/config/m68k/haiku.h
index 358c19f..9e47da4 100644
a
|
b
|
Boston, MA 02110-1301, USA. */
|
108 | 108 | |
109 | 109 | #undef LINK_SPEC |
110 | 110 | /*#define LINK_SPEC "%{!o*:-o %b} -m elf_m68k_haiku -shared -no-undefined %{nostart:-e 0}"*/ |
111 | | #define LINK_SPEC "%{!o*:-o %b} -m m68kelf %{!r:-shared} -no-undefined %{nostart:-e 0}" |
| 111 | #define LINK_SPEC "%{!o*:-o %b} -m m68kelf %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} -no-undefined %{nostart:-e 0}" |
112 | 112 | |
113 | 113 | /* XXX: not sure for the rest there... */ |
114 | 114 | |
diff --git a/gcc/gcc/config/mips/haiku.h b/gcc/gcc/config/mips/haiku.h
index f6d2efb..412d195 100644
a
|
b
|
Boston, MA 02111-1307, USA. */
|
40 | 40 | while (0) |
41 | 41 | |
42 | 42 | #undef LINK_SPEC |
43 | | #define LINK_SPEC "%{!o*:-o %b} -m elf_mipsel_haiku %{!r:-shared} %{nostart:-e 0}" |
| 43 | #define LINK_SPEC "%{!o*:-o %b} -m elf_mipsel_haiku %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} %{nostart:-e 0}" |
44 | 44 | |
diff --git a/gcc/gcc/config/rs6000/haiku.h b/gcc/gcc/config/rs6000/haiku.h
index 9ff36f1..17c71eb 100644
a
|
b
|
Boston, MA 02111-1307, USA. */
|
53 | 53 | /* If ELF is the default format, we should not use /lib/elf. */ |
54 | 54 | |
55 | 55 | #undef LINK_SPEC |
56 | | #define LINK_SPEC "%{!o*:-o %b} -m elf32ppchaiku %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}" |
| 56 | #define LINK_SPEC "%{!o*:-o %b} -m elf32ppchaiku %{shared|r|pie|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-pie --allow-shlib-undefined --export-dynamic} %{nostart:-e 0} %{shared:-shared -e 0} %{!shared: %{!nostart: -no-undefined}}" |
57 | 57 | |
58 | 58 | #undef CC1_SPEC |
59 | | #define CC1_SPEC "%{!no-fpic:%{!fno-pic:%{!fno-pie:%{!fpie:%{!fPIC:%{!fPIE:-fPIC}}}}}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" |
| 59 | #define CC1_SPEC "%{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-fPIC} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}" |