Bug#340255: gcc-34: [Patch] Support PIE for M32R
Package: gcc-3.4
Version: 3.4.4-10
Severity: wishlist
Tags: patch
Could you please include following patch?
This patch is enable to use PIE at gcc for M32R.
* debian/patches/m32r-pie.dpatch: Enable PIE for M32R.
#! /bin/sh -e
#
#
# DP: Author: Kazuhiro Inaoka
# DP: Status: in CVS 4.0-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 2005-07-29 19:31:19.000000000 +0900
+++ gcc-3.4.4/gcc/config.gcc 2005-07-29 19:30:07.000000000 +0900
@@ -1313,7 +1313,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"
tmake_file="t-slibgcc-elf-ver m32r/t-linux"
gnu_ld=yes
use_fixproto=yes
@@ -1323,7 +1322,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"
tmake_file="t-slibgcc-elf-ver m32r/t-linux"
gnu_ld=yes
use_fixproto=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: