Bug when generating Program Header in elf files
Nick Clifton
nickc@cambridge.redhat.com
Tue Jun 12 07:06:00 GMT 2001
Hi Thomas,
As you have discovered this problem happens because your linker
script did not explicitly assign .rodata sections in the input files
to a section in the output file.
The algorithm used to decide where to place these unallocated
sections (called 'orphan sections') changed with binutils 2.11, so
that were being placed at the start of file rather than the end of
the file, and this meant a second (correctly specified) program
header was needed.
Although you have already solved the problem by fixing your linker
script, you may also want to try the patch below, which changes the
orphan placement algorithm slitghtly so that unallocates .rodata
sections will now be attached to the .data section.
Cheers
Nick
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.48
diff -p -r1.48 elf32.em
*** elf32.em 2001/05/25 05:39:22 1.48
--- elf32.em 2001/06/12 14:04:20
*************** gld${EMULATION_NAME}_place_orphan (file,
*** 1097,1105 ****
&& (hold_rel.os != NULL
|| (hold_rel.os = output_rel_find ()) != NULL))
place = &hold_rel;
! else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY
! && HAVE_SECTION (hold_rodata, ".rodata"))
! place = &hold_rodata;
else if ((s->flags & (SEC_CODE | SEC_READONLY)) == (SEC_CODE | SEC_READONLY)
&& hold_text.os != NULL)
place = &hold_text;
--- 1097,1111 ----
&& (hold_rel.os != NULL
|| (hold_rel.os = output_rel_find ()) != NULL))
place = &hold_rel;
! else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY)
! {
! if (HAVE_SECTION (hold_rodata, ".rodata"))
! place = &hold_rodata;
! /* If the script does not provide a .rodata
! section try using the .data section instead. */
! else if (HAVE_SECTION (hold_data, ".data"))
! place = &hold_data;
! }
else if ((s->flags & (SEC_CODE | SEC_READONLY)) == (SEC_CODE | SEC_READONLY)
&& hold_text.os != NULL)
place = &hold_text;
More information about the Binutils
mailing list