Skip to content

Commit 806c8b4

Browse files
kito-chengcmuellner
authored andcommitted
Add --enable-default-pie option
`--enable-default-pie` is used to control the default PIE enablement for Linux GCC, which is disabled by default. NOTE: baremetal toolchain isn't affected by this option.
1 parent 0b4a598 commit 806c8b4

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Makefile.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PK_SRCDIR := @with_pk_src@
1515
LLVM_SRCDIR := @with_llvm_src@
1616
DEJAGNU_SRCDIR := @with_dejagnu_src@
1717
DEBUG_INFO := @debug_info@
18+
ENABLE_DEFAULT_PIE := @enable_default_pie@
1819
DEJAGNU_SRCDIR := @with_dejagnu_src@
1920

2021
SIM ?= @WITH_SIM@
@@ -470,6 +471,7 @@ stamps/build-gcc-linux-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binutil
470471
--disable-nls \
471472
--disable-bootstrap \
472473
--src=$(gccsrcdir) \
474+
$(ENABLE_DEFAULT_PIE) \
473475
$(GCC_CHECKING_FLAGS) \
474476
$(MULTILIB_FLAGS) \
475477
$(WITH_ABI) \
@@ -506,6 +508,7 @@ stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/b
506508
--disable-nls \
507509
--disable-bootstrap \
508510
--src=$(gccsrcdir) \
511+
$(ENABLE_DEFAULT_PIE) \
509512
$(GCC_CHECKING_FLAGS) \
510513
$(MULTILIB_FLAGS) \
511514
$(WITH_ABI) \
@@ -814,6 +817,7 @@ stamps/build-gcc-musl-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binutils
814817
--disable-nls \
815818
--disable-bootstrap \
816819
--src=$(gccsrcdir) \
820+
$(ENABLE_DEFAULT_PIE) \
817821
$(GCC_CHECKING_FLAGS) \
818822
--disable-multilib \
819823
$(WITH_ABI) \
@@ -883,6 +887,7 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-lin
883887
--disable-nls \
884888
--disable-bootstrap \
885889
--src=$(gccsrcdir) \
890+
$(ENABLE_DEFAULT_PIE) \
886891
$(GCC_CHECKING_FLAGS) \
887892
--disable-multilib \
888893
$(WITH_ABI) \

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ The musl compiler (riscv64-unknown-linux-musl-) will only be able to target
105105
The `--enable-multilib` flag therefore does not actually enable multilib support
106106
for musl libc.
107107

108+
Linux toolchain has an additional option `--enable-default-pie` to control the
109+
default PIE enablement for GCC, which is disable by default.
110+
108111
### Troubleshooting Build Problems
109112

110113
Builds work best if installing into an empty directory. If you build a

configure

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ WITH_ISA_SPEC
619619
WITH_TUNE
620620
WITH_ABI
621621
WITH_ARCH
622+
enable_default_pie
622623
debug_info
623624
default_target
624625
FETCHER
@@ -681,6 +682,7 @@ ac_user_opts='
681682
enable_option_checking
682683
enable_linux
683684
enable_debug_info
685+
enable_default_pie
684686
with_arch
685687
with_abi
686688
with_tune
@@ -1335,6 +1337,8 @@ Optional Features:
13351337
[--disable-linux]
13361338
--enable-debug-info build glibc/musl/newlibc/libgcc with debug
13371339
information
1340+
--enable-default-pie build linux toolchain with default PIE
1341+
[--enable-default-pie]
13381342
--enable-multilib build both RV32 and RV64 runtime libraries (only
13391343
RV64 for musl libc) [--disable-multilib]
13401344
--enable-gcc-checking Enable gcc internal checking, it will make gcc very
@@ -3330,6 +3334,24 @@ else
33303334
33313335
fi
33323336
3337+
# Check whether --enable-default-pie was given.
3338+
if test "${enable_default_pie+set}" = set; then :
3339+
enableval=$enable_default_pie;
3340+
else
3341+
enable_default_pie=no
3342+
3343+
fi
3344+
3345+
3346+
if test "x$enable_default_pie" != xyes; then :
3347+
enable_default_pie="--disable-default-pie"
3348+
3349+
else
3350+
enable_default_pie="--enable-default-pie"
3351+
3352+
fi
3353+
3354+
33333355
33343356
# Check whether --with-arch was given.
33353357
if test "${with_arch+set}" = set; then :

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ AS_IF([test "x$enable_debug_info" != xyes],
6767
[AC_SUBST(debug_info, "")],
6868
[AC_SUBST(debug_info, "-g")])
6969

70+
AC_ARG_ENABLE(default-pie,
71+
[AS_HELP_STRING([--enable-default-pie],
72+
[build linux toolchain with default PIE @<:@--enable-default-pie@:>@])],
73+
[],
74+
[enable_default_pie=no]
75+
)
76+
77+
AS_IF([test "x$enable_default_pie" != xyes],
78+
[AC_SUBST(enable_default_pie, "--disable-default-pie")],
79+
[AC_SUBST(enable_default_pie, "--enable-default-pie")])
80+
81+
7082
AC_ARG_WITH(arch,
7183
[AS_HELP_STRING([--with-arch=rv64imafdc],
7284
[Sets the base RISC-V ISA, defaults to rv64imafdc])],

0 commit comments

Comments
 (0)