This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Adding ELF sections with bfd
- From: Alan Modra <amodra at gmail dot com>
- To: Jack Carter <Jack dot Carter at imgtec dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 25 Jun 2013 15:32:18 +0930
- Subject: Re: Adding ELF sections with bfd
- References: <4CEFBC1BE64A8048869F799EF2D2EEEE01AA0974 at BADAG02 dot ba dot imgtec dot org>
On Tue, Jun 25, 2013 at 12:43:33AM +0000, Jack Carter wrote:
> Hi,
>
> This is a bit embarrassing, but I am having trouble generating a section, in this case .iplt.
>
> I instigate the creation with a call to bfd_make_section_anyway_with_flags:
>
> s = bfd_make_section_anyway_with_flags(dynobj, ".iplt",
> flags | SEC_READONLY | SEC_CODE);
> if (s == NULL
> || !bfd_set_section_alignment(dynobj, s, bed->plt_alignment))
> return FALSE;
> htab->root.iplt = s;
> htab->siplt = s;
> htab->iplt_entry_size = 4 * ARRAY_SIZE (mips_exec_iplt_entry);
>
> but later when I want to reference the address of the output section in mips_elf_calculate_relocation(), it doesn't seem to be there. This during bfd_elf_final_link() so I would assume that all the output sections have been allocated by this time.
>
> What is the magic to having a new section get an output_section allocated to it.
How are you trying to find the output section? By looking up .iplt in
the output bfd? That might fail due to a linker script mapping .iplt
to some other section.
Also, at what stage of linking are you creating your dynobj .iplt?
You need to do so before ldlang.c:map_input_to_output_sections() for
it to be given an output section (strictly speaking last chance is
lang_place_orphans()).
--
Alan Modra
Australia Development Lab, IBM