From 776cf5543b567f781b1b87c31ade51cb04c98e8f Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Fri, 6 May 2016 06:46:27 +0300 Subject: [PATCH] Fix compatibility with Linaro toolchains for building ARM binaries Add DISCARD directives to the linker scripts and also -marm option to GCC command line. Without this, certain toolchains may build Thumb2 code by default. Also junk sections may be present in the final binary and they need to be removed. This helps at least when using the following Linaro toolchain: gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf.tar.xz Signed-off-by: Siarhei Siamashka Reviewed-by: Bernhard Nortmann --- Makefile | 2 +- boot_head.lds | 17 +++++++++++------ fel-pio.lds | 17 +++++++++++------ fel-sdboot.lds | 17 +++++++++++------ jtag-loop.lds | 17 +++++++++++------ 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 59e8641..e1dcb8a 100644 --- a/Makefile +++ b/Makefile @@ -121,7 +121,7 @@ sunxi-%: %.c fel-pio.bin: fel-pio.elf fel-pio.nm -ARM_ELF_FLAGS = -Os -fpic -Wall +ARM_ELF_FLAGS = -Os -marm -fpic -Wall ARM_ELF_FLAGS += -fno-common -fno-builtin -ffreestanding -nostdinc ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security diff --git a/boot_head.lds b/boot_head.lds index 278f530..4fdbc6d 100644 --- a/boot_head.lds +++ b/boot_head.lds @@ -14,10 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - SECTIONS - { - . = 0x40007000; - .text : { *(.text) } - } - +SECTIONS +{ + . = 0x40007000; + .text : { *(.text) } + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note*) } +} diff --git a/fel-pio.lds b/fel-pio.lds index 618070c..f35da1a 100644 --- a/fel-pio.lds +++ b/fel-pio.lds @@ -14,10 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - SECTIONS - { - . = 0x2000; - .text : { *(.text) } - } - +SECTIONS +{ + . = 0x2000; + .text : { *(.text) } + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note*) } +} diff --git a/fel-sdboot.lds b/fel-sdboot.lds index 67bff97..9ba718d 100644 --- a/fel-sdboot.lds +++ b/fel-sdboot.lds @@ -14,10 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - SECTIONS - { - . = 0x0030; - .text : { *(.text) } - } - +SECTIONS +{ + . = 0x0030; + .text : { *(.text) } + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note*) } +} diff --git a/jtag-loop.lds b/jtag-loop.lds index 67bff97..9ba718d 100644 --- a/jtag-loop.lds +++ b/jtag-loop.lds @@ -14,10 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - SECTIONS - { - . = 0x0030; - .text : { *(.text) } - } - +SECTIONS +{ + . = 0x0030; + .text : { *(.text) } + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.note*) } +}