Bug#363456: gcc-4.0: [Patch] Support PIE for M32R
Package: gcc-4.0
Version: 4.0.3-1
Severity: wishlist
Tags: patch
Could you please add the following patch ?
This patch is to support PIE option.
It was applied to gcc-4.1-branch.
Regards,
Kazuhiro Inaoka
#! /bin/sh -e
#
#
# DP: Author: Kazuhiro Inaoka
# DP: Status: in CVS 4.1-branch
# DP: PIE Support
if [ $# -eq 3 ] && [ "$2" = '-d' ]; then
pdir="-d $3"
dir="$3/"
elif [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0;;
-unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
--- gcc-3.4.4/gcc/config.gcc.org 2006-04-19 16:16:31.000000000 +0900
+++ gcc-3.4.4/gcc/config.gcc 2006-04-19 16:17:07.000000000 +0900
@@ -1293,7 +1293,6 @@
;;
m32r-*-linux*)
tm_file="dbxelf.h elfos.h svr4.h linux.h ${tm_file} m32r/linux.h"
- extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
# We override the tmake_file for linux -- why?
tmake_file="t-slibgcc-elf-ver m32r/t-linux"
gnu_ld=yes
@@ -1304,7 +1303,6 @@
;;
m32rle-*-linux*)
tm_file="dbxelf.h elfos.h svr4.h linux.h m32r/little.h ${tm_file} m32r/linux.h"
- extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
# We override the tmake_file for linux -- why?
tmake_file="t-slibgcc-elf-ver m32r/t-linux"
gnu_ld=yes
--- gcc-3.4.4/gcc/config/m32r/m32r.h.org 2005-07-29 19:22:12.000000000 +0900
+++ gcc-3.4.4/gcc/config/m32r/m32r.h 2005-07-29 19:24:34.000000000 +0900
@@ -191,7 +191,7 @@
/* Options to pass on to the assembler. */
#undef ASM_SPEC
-#define ASM_SPEC "%{v} %(asm_cpu) %(relax) %{fpic:-K PIC} %{fPIC:-K PIC}"
+#define ASM_SPEC "%{v} %(asm_cpu) %(relax) %{fpic|fpie:-K PIC} %{fPIC|fPIE:-K PIC}"
#define LINK_SPEC "%{v} %(link_cpu) %(relax)"
--- gcc-3.4.4/gcc/config/m32r/linux.h.org 2005-07-29 19:22:21.000000000 +0900
+++ gcc-3.4.4/gcc/config/m32r/linux.h 2005-07-29 19:24:50.000000000 +0900
@@ -85,14 +85,20 @@
%{profile:-lc_p} %{!profile: -lc}}"
#undef STARTFILE_SPEC
+#if defined HAVE_LD_PIE
+#define STARTFILE_SPEC \
+ "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#else
#define STARTFILE_SPEC \
"%{!shared: \
%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+#endif
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+ "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "\
Reply to: