[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arm-*-*-ld --oformat binary SEGMENTATION FAULT
From: |
Nick Clifton |
Subject: |
Re: arm-*-*-ld --oformat binary SEGMENTATION FAULT |
Date: |
Wed, 22 Oct 2008 15:21:56 +0100 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080723) |
Hi Marco,
I have encountered a problem linking a binary format executable with
target ARM. No matter whatever I link, when I use --oformat binary the
result is always the same: segmentation fault.
It is a known problem for the ARM port of the linker that you cannot
convert to the binary format at the same time as performing a final
link. You have to link to the default output format first and then use
objcopy to convert the resulting executable into the binary file format.
There is a check in the ARM portion of the linker's source code which
detects when the output format is changed and issues an error message,
but unfortunately this test was being performed too late. I will be
applying the attached patch to fix this. With the patch applied I now
get this output when running your test case:
% arm-angstrom-linux-gnueabi-ld -o source.bin --oformat binary
source.o
error: Cannot change output format whilst linking ARM binaries.
Cheers
Nick
ld/ChangeLog
2008-10-22 Nick Clifton <address@hidden>
* emultempl/armelf.em (arm_elf_after_open): Move check for using a
non-arm output target from here...
(arm_elf_create_output_section_statements): ... to here, so that
the check is made at the earliest possible opportunity.
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.67
diff -c -3 -p -r1.67 armelf.em
*** ld/emultempl/armelf.em 21 Oct 2008 22:20:29 -0000 1.67
--- ld/emultempl/armelf.em 22 Oct 2008 14:21:21 -0000
*************** gld${EMULATION_NAME}_before_parse (void)
*** 55,70 ****
static void
arm_elf_after_open (void)
{
- if (strstr (bfd_get_target (link_info.output_bfd), "arm") == NULL)
- {
- /* The arm backend needs special fields in the output hash structure.
- These will only be created if the output format is an arm format,
- hence we do not support linking and changing output formats at the
- same time. Use a link followed by objcopy to change output formats.
*/
- einfo ("%F%X%P: error: cannot change output format whilst linking ARM
binaries\n");
- return;
- }
-
{
LANG_FOR_EACH_INPUT_STATEMENT (is)
{
--- 55,60 ----
*************** gld${EMULATION_NAME}_finish (void)
*** 439,444 ****
--- 429,444 ----
static void
arm_elf_create_output_section_statements (void)
{
+ if (strstr (bfd_get_target (link_info.output_bfd), "arm") == NULL)
+ {
+ /* The arm backend needs special fields in the output hash structure.
+ These will only be created if the output format is an arm format,
+ hence we do not support linking and changing output formats at the
+ same time. Use a link followed by objcopy to change output formats.
*/
+ einfo ("%F%X%P: error: Cannot change output format whilst linking ARM
binaries.\n");
+ return;
+ }
+
bfd_elf32_arm_set_target_relocs (link_info.output_bfd, &link_info,
target1_is_rel,
target2_type, fix_v4bx, use_blx,