This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: binutils patches for basic generic i960-elf



I came across a problem when trying to improve my i960-*-elf
configuration of the egcs compiler.

My bfd config uses the generic linker - it doesn't provide an
i960-elf-specific backend relocate_section().  When I try to do a
relocatable link of two files containing simply:

.section .gnu.linkonce.t.GetLength__C6Marble
 .stabd 68,0,4

I get a link error "link: symbol `L0`' required but not present".  The
problem comes because the .stabd causes a local symbol to be generated
in order for a stab relocation to refer to.  The second duplicate of the
linkonce section gets correctly discarded, along with this local
symbol.  When the linker comes to output the relocations for the .stab
section, it fails because it has to output a relocation that refers to a
symbol that isn't being output.

I looked at what the local x86/linux linker does.  It outputs the local
symbol which has been frobbed to point to the *ABS* section.  The code
that causes this is in elf_link_input_bfd() (search for "needed by a
reloc").  I'm wondering whether or not it would be a good idea for the
generic linker to support the same behaviour - when scanning the relocs,
output any symbols that haven't been already output.  This seemed a bit
complicated to do - involving perhaps passing the
generic_write_global_symbol_info to bfd_canonicalize_relocs() to
elf_slurp_reloc_table().

It would be quite possible for the linker to go one better than
elf_link_input_bfd() does at the moment, and make the output symbol
refer to the correct place in the correct section.  One idea I had for
doing this was to add a field to asection - asection* duplicate_of; -
which the linker (ldlang.c:section_already_linked()) would fill in when
it decides to discard a duplicate linkonce section.  Later on, when
scanning the relocs and coming across a symbol in a section that has a
duplicate_of and an output_section of bfd_abs_section, the linker could
output a symbol with the value of the original symbol plus the offset of
the duplicate_of section in the output section and fix the reloc to
refer to this.

More realistically, if the current behaviour is not right, then it might
be worthwhile documenting it for the benefit of anyone creating a new
elf architecture.

--



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]