Discussion:
[uClinux-dev] [PATCH v2] allow to build arm flat binaries
Waldemar Brodkorb
2016-03-14 05:01:58 UTC
Permalink
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.

Signed-off-by: Waldemar Brodkorb <***@openadk.org>
---

v1 -> v2:
- segfault problem fixed, r_mem pointer should be initialized
- v1 was successfully tested by Thomas Petazzoni with buildroot
generated image for STM32F429

---
elf2flt.c | 11 ++++++++++-
elf2flt.ld.in | 17 ++++++++++++++---
2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/elf2flt.c b/elf2flt.c
index fcd797c..7d0e639 100644
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -56,6 +56,8 @@ const char *elf2flt_progname;

#if defined(TARGET_h8300)
#include <elf/h8.h> /* TARGET_* ELF support for the BFD library */
+#elif defined(TARGET_arm)
+#include <elf/arm.h>
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(TARGET_nios) || defined(TARGET_nios2)
#include "cygwin-elf.h" /* Cygwin uses a local copy */
#elif defined(TARGET_xtensa)
@@ -451,7 +453,7 @@ dump_symbols(symbols, number_of_symbols);
qsort (relpp, relcount, sizeof *relpp, compare_relocs);
#endif
for (p = relpp; (relcount && (*p != NULL)); p++, relcount--) {
- unsigned char *r_mem;
+ unsigned char *r_mem = NULL;
int relocation_needed = 0;

#ifdef TARGET_microblaze
@@ -646,16 +648,23 @@ dump_symbols(symbols, number_of_symbols);
default:
goto good_32bit_resolved_reloc;
#elif defined(TARGET_arm)
+ case R_ARM_TARGET1:
+ case R_ARM_TARGET2:
case R_ARM_ABS32:
relocation_needed = 1;
break;
case R_ARM_REL32:
+ case R_ARM_JUMP24:
+ case R_ARM_CALL:
case R_ARM_THM_PC11:
case R_ARM_THM_PC22:
+ case R_ARM_THM_JUMP24:
case R_ARM_PC24:
case R_ARM_PLT32:
case R_ARM_GOTPC:
case R_ARM_GOT32:
+ case R_ARM_PREL31:
+ case R_ARM_NONE:
relocation_needed = 0;
break;
default:
diff --git a/elf2flt.ld.in b/elf2flt.ld.in
index bfda0ef..ec1fe6f 100644
--- a/elf2flt.ld.in
+++ b/elf2flt.ld.in
@@ -35,6 +35,8 @@ W_RODAT *(.rodata1)
W_RODAT *(.rodata.*)
W_RODAT *(.gnu.linkonce.r*)

+ /* .ARM.extab name sections containing exception unwinding information */
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
/* This is special code area at the end of the normal
text section. It contains a small lookup table at
the start followed by the code pointed to by entries
@@ -43,11 +45,20 @@ W_RODAT *(.gnu.linkonce.r*)
PROVIDE(@***@__ctbp = .);
*(.call_table_data)
*(.call_table_text)
-
- . = ALIGN(0x20) ;
- @***@_etext = . ;
} > flatmem :text

+ /* .ARM.exidx name sections containing index entries for section unwinding */
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ @***@__exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > flatmem
+ @***@__exidx_end = .;
+
+ . = ALIGN(0x20) ;
+ @***@_etext = . ;
+
.data : {
. = ALIGN(0x4) ;
@***@_sdata = . ;
--
1.7.10.4

_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Greg Ungerer
2016-03-19 03:53:49 UTC
Permalink
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).

Regards
Greg
Post by Waldemar Brodkorb
- segfault problem fixed, r_mem pointer should be initialized
- v1 was successfully tested by Thomas Petazzoni with buildroot
generated image for STM32F429
---
elf2flt.c | 11 ++++++++++-
elf2flt.ld.in | 17 ++++++++++++++---
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/elf2flt.c b/elf2flt.c
index fcd797c..7d0e639 100644
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -56,6 +56,8 @@ const char *elf2flt_progname;
#if defined(TARGET_h8300)
#include <elf/h8.h> /* TARGET_* ELF support for the BFD library */
+#elif defined(TARGET_arm)
+#include <elf/arm.h>
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(TARGET_nios) || defined(TARGET_nios2)
#include "cygwin-elf.h" /* Cygwin uses a local copy */
#elif defined(TARGET_xtensa)
@@ -451,7 +453,7 @@ dump_symbols(symbols, number_of_symbols);
qsort (relpp, relcount, sizeof *relpp, compare_relocs);
#endif
for (p = relpp; (relcount && (*p != NULL)); p++, relcount--) {
- unsigned char *r_mem;
+ unsigned char *r_mem = NULL;
int relocation_needed = 0;
#ifdef TARGET_microblaze
@@ -646,16 +648,23 @@ dump_symbols(symbols, number_of_symbols);
goto good_32bit_resolved_reloc;
#elif defined(TARGET_arm)
relocation_needed = 1;
break;
relocation_needed = 0;
break;
diff --git a/elf2flt.ld.in b/elf2flt.ld.in
index bfda0ef..ec1fe6f 100644
--- a/elf2flt.ld.in
+++ b/elf2flt.ld.in
@@ -35,6 +35,8 @@ W_RODAT *(.rodata1)
W_RODAT *(.rodata.*)
W_RODAT *(.gnu.linkonce.r*)
+ /* .ARM.extab name sections containing exception unwinding information */
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
/* This is special code area at the end of the normal
text section. It contains a small lookup table at
the start followed by the code pointed to by entries
@@ -43,11 +45,20 @@ W_RODAT *(.gnu.linkonce.r*)
*(.call_table_data)
*(.call_table_text)
-
- . = ALIGN(0x20) ;
} > flatmem :text
+ /* .ARM.exidx name sections containing index entries for section unwinding */
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > flatmem
+
+ . = ALIGN(0x20) ;
+
.data : {
. = ALIGN(0x4) ;
@***@_sdata = . ;
_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Greg Ungerer
2016-08-18 07:24:36 UTC
Permalink
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.

The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.

Regards
Greg
Post by Greg Ungerer
Post by Waldemar Brodkorb
- segfault problem fixed, r_mem pointer should be initialized
- v1 was successfully tested by Thomas Petazzoni with buildroot
generated image for STM32F429
---
elf2flt.c | 11 ++++++++++-
elf2flt.ld.in | 17 ++++++++++++++---
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/elf2flt.c b/elf2flt.c
index fcd797c..7d0e639 100644
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -56,6 +56,8 @@ const char *elf2flt_progname;
#if defined(TARGET_h8300)
#include <elf/h8.h> /* TARGET_* ELF support for the BFD library */
+#elif defined(TARGET_arm)
+#include <elf/arm.h>
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(TARGET_nios) || defined(TARGET_nios2)
#include "cygwin-elf.h" /* Cygwin uses a local copy */
#elif defined(TARGET_xtensa)
@@ -451,7 +453,7 @@ dump_symbols(symbols, number_of_symbols);
qsort (relpp, relcount, sizeof *relpp, compare_relocs);
#endif
for (p = relpp; (relcount && (*p != NULL)); p++, relcount--) {
- unsigned char *r_mem;
+ unsigned char *r_mem = NULL;
int relocation_needed = 0;
#ifdef TARGET_microblaze
@@ -646,16 +648,23 @@ dump_symbols(symbols, number_of_symbols);
goto good_32bit_resolved_reloc;
#elif defined(TARGET_arm)
relocation_needed = 1;
break;
relocation_needed = 0;
break;
diff --git a/elf2flt.ld.in b/elf2flt.ld.in
index bfda0ef..ec1fe6f 100644
--- a/elf2flt.ld.in
+++ b/elf2flt.ld.in
@@ -35,6 +35,8 @@ W_RODAT *(.rodata1)
W_RODAT *(.rodata.*)
W_RODAT *(.gnu.linkonce.r*)
+ /* .ARM.extab name sections containing exception unwinding information */
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
/* This is special code area at the end of the normal
text section. It contains a small lookup table at
the start followed by the code pointed to by entries
@@ -43,11 +45,20 @@ W_RODAT *(.gnu.linkonce.r*)
*(.call_table_data)
*(.call_table_text)
-
- . = ALIGN(0x20) ;
} > flatmem :text
+ /* .ARM.exidx name sections containing index entries for section unwinding */
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > flatmem
+
+ . = ALIGN(0x20) ;
+
.data : {
. = ALIGN(0x4) ;
@***@_sdata = . ;
Waldemar Brodkorb
2016-08-18 22:48:12 UTC
Permalink
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
fails on boot while executing one of the startup scripts:

[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)

Without the patch the system boots up fine.

Best regards
Waldemar
_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Greg Ungerer
2016-08-22 04:28:20 UTC
Permalink
Hi Waldemar,
Post by Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)
Without the patch the system boots up fine.
Ok, thanks for the feedback.

Can you try this patch instead then?
It keeps the ARM.edix table at the same relative position, but moves
the _etext symbol to be after the ARM.eidx table. The ARM.eidx section
is marked as read-only in the linked ELF file.

Regards
Greg
Waldemar Brodkorb
2016-08-24 21:35:24 UTC
Permalink
Hi,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)
Without the patch the system boots up fine.
Ok, thanks for the feedback.
Can you try this patch instead then?
It keeps the ARM.edix table at the same relative position, but moves
the _etext symbol to be after the ARM.eidx table. The ARM.eidx section
is marked as read-only in the linked ELF file.
This works for me.
What application is breaking without it?

best regards
Waldemar
_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Greg Ungerer
2016-08-25 01:30:32 UTC
Permalink
Hi Waldemar,
Post by Waldemar Brodkorb
Hi,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)
Without the patch the system boots up fine.
Ok, thanks for the feedback.
Can you try this patch instead then?
It keeps the ARM.edix table at the same relative position, but moves
the _etext symbol to be after the ARM.eidx table. The ARM.eidx section
is marked as read-only in the linked ELF file.
This works for me.
What application is breaking without it?
Not a specific application. The problem I was trying to solve
was for code compiled PIC. And specifically the case where the
text and data sections where loading at non-contiguous RAM
addresses.

In the end problem is not so much this (this change only ended
up added a ":text" to to the flatmem redirection of the segment
contents). The problem actually seems to be related to code
generation for symbols with hidden visibility - for the PIC
case they where being loaded via PC relative instructions and
not using register indirect via the designated base register.

Anyway, for now I don't think this patch is necessary, so you
can ignore it.

Regards
Greg


_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Waldemar Brodkorb
2016-08-27 11:25:40 UTC
Permalink
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)
Without the patch the system boots up fine.
Ok, thanks for the feedback.
Can you try this patch instead then?
It keeps the ARM.edix table at the same relative position, but moves
the _etext symbol to be after the ARM.eidx table. The ARM.eidx section
is marked as read-only in the linked ELF file.
This works for me.
What application is breaking without it?
Not a specific application. The problem I was trying to solve
was for code compiled PIC. And specifically the case where the
text and data sections where loading at non-contiguous RAM
addresses.
In the end problem is not so much this (this change only ended
up added a ":text" to to the flatmem redirection of the segment
contents). The problem actually seems to be related to code
generation for symbols with hidden visibility - for the PIC
case they where being loaded via PC relative instructions and
not using register indirect via the designated base register.
Anyway, for now I don't think this patch is necessary, so you
can ignore it.
Okay. Do you think disabling DOPIC in uClibc-ng is related to the
problem? Did you have DOPIC on or off for ypur ARM noMMU tests?

I have to disable it.

best regards
Waldemar
_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
Greg Ungerer
2016-08-29 05:00:12 UTC
Permalink
Hi Waldemar,
Post by Waldemar Brodkorb
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
Post by Greg Ungerer
Hi Waldemar,
Post by Greg Ungerer
Hi Waldemar,
Post by Waldemar Brodkorb
Add patchset from ptxdist which is required to produce working
ARM flat binaries. Tested with busybox on Kinetis K70.
Thanks. Applied to the github elf2flt repository (with Thomas'
Tested-by).
The adding of the ARM.eidx section in this patch breaks binaries
that have a global offset table (GOT). I propose the attached fix
that puts it within the data section proper - and not effectively
at the start of the data section.
The original patch would have no impact on fully relocated
binaries, generally only those compiled with -fpic or similar.
I tested your patch with Buildroot on a STM32F29 device, but it
[ 0.650000] STM32 USART driver initialized
[ 0.650000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 17, base_baud = 5625000) is a stm32-usart
[ 0.890000] console [ttyS0] enabled
[ 0.910000] Freeing unused kernel memory: 12K (9000a000 - 9000d000) In
[ 1.260000]
[ 1.260000] Unhandled exception: IPSR = 00000003 LR = fffffff1
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] task: 90550000 ti: 9055a000 task.ti: 9055a000
[ 1.260000] PC is at 0x21000000
[ 1.260000] LR is at 0xfffffffd
[ 1.260000] pc : [<21000000>] lr : [<fffffffd>] psr: 40000035
[ 1.260000] sp : 9055bff8 ip : 9055bfe0 fp : 90555008
[ 1.260000] r10: 00000000 r9 : 00000003 r8 : 00000024
[ 1.260000] r7 : 00000072 r6 : 906ccad8 r5 : 00000000 r4 : 00000072
[ 1.260000] r3 : 00000000 r2 : 00000003 r1 : 906ccafc r0 : ffffffff
[ 1.260000] xPSR: 40000035
[ 1.260000] CPU: 0 PID: 26 Comm: S20urandom Not tainted 4.5.0 #2
[ 1.260000] Hardware name: STM32 (Device Tree Support)
[ 1.260000] [<0800bd41>] (unwind_backtrace) from [<0800b0df>] (show_stack+0xb/0xc)
[ 1.260000] [<0800b0df>] (show_stack) from [<0800b68f>] (__invalid_entry+0x4b/0x4c)
Without the patch the system boots up fine.
Ok, thanks for the feedback.
Can you try this patch instead then?
It keeps the ARM.edix table at the same relative position, but moves
the _etext symbol to be after the ARM.eidx table. The ARM.eidx section
is marked as read-only in the linked ELF file.
This works for me.
What application is breaking without it?
Not a specific application. The problem I was trying to solve
was for code compiled PIC. And specifically the case where the
text and data sections where loading at non-contiguous RAM
addresses.
In the end problem is not so much this (this change only ended
up added a ":text" to to the flatmem redirection of the segment
contents). The problem actually seems to be related to code
generation for symbols with hidden visibility - for the PIC
case they where being loaded via PC relative instructions and
not using register indirect via the designated base register.
Anyway, for now I don't think this patch is necessary, so you
can ignore it.
Okay. Do you think disabling DOPIC in uClibc-ng is related to the
problem? Did you have DOPIC on or off for ypur ARM noMMU tests?
I have to disable it.
Yes, I have to disable it too. Having DOPIC on will compile the
lib code with -fPIC - and that is where I see some problems.
Not sure of the root of those problems yet, but you get access
being attempted outside of the text and data when they are loaded
in separate memory regions.

Regards
Greg


_______________________________________________
uClinux-dev mailing list
uClinux-***@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-***@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Continue reading on narkive:
Loading...