public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: Where to put per-target global BFD data ?
  1999-07-01  0:00   ` Jeffrey A Law
@ 1999-07-01  0:00     ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 1999-07-01  0:00 UTC (permalink / raw)
  To: law; +Cc: rth, nickc, binutils

   Date: Mon, 21 Jun 1999 03:26:42 -0600
   From: Jeffrey A Law <law@cygnus.com>

     In message < 19990620164714.B4699@cygnus.com >you write:
     > >   I am not sure how this can be fixed.  I think using the hash table
     > >   may not be the best way to store global information, because of this
     > >   problem, and that another solution needs to be found.
     > 
     > My solution would be to outlaw linking together different formats,
     > and that the output format must match the input format.  Diddling
     > different formats is what objcopy is for.
   I've got no problems with that.  multi-format linking was always an interesting
   idea, but it never worked well and worked even less well when the linker was
   changed to use native relocs instead of bfd relocs.  And I haven't seen that
   multi-format linking has been all that important to the user community.

There are people who use it, though, mainly because they have compiled
objects from somebody for which they do not have the source.  I've
seen probably a dozen bug reports on it over the years.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Where to put per-target global BFD data ?
@ 1999-07-01  0:00 Nick Clifton
  1999-07-01  0:00 ` Ian Lance Taylor
  1999-07-01  0:00 ` Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Nick Clifton @ 1999-07-01  0:00 UTC (permalink / raw)
  To: binutils

Hi Guys,

  I have come across a problem with storing target specific global
  data in BFD.  Currently targets like the ARM ports create an
  extended version of the link hash table, override the default 
  link_hash_table_create function with their own version, and then
  store their data in the new fields now available.

  This fails however, when the output format is not the same as the
  input format.  For example linking together a coff-arm object file
  with the command line:

       ld -oformat srec foo.o

  will fail with a segmentation fault because the hash in the
  link_info structure gets created based on the output format (srec)
  not the input format (coff-arm).  The srec format does not create an
  extended structure on the end of the hash table, and so the coff-arm
  routines that get called later, and which assume that the coff-arm
  version of link_hash_table_create has been called, try to use data
  which is not there. 

  I am not sure how this can be fixed.  I think using the hash table
  may not be the best way to store global information, because of this
  problem, and that another solution needs to be found.

  Any suggestions ?

Cheers
	Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Where to put per-target global BFD data ?
  1999-07-01  0:00 ` Richard Henderson
@ 1999-07-01  0:00   ` Jeffrey A Law
  1999-07-01  0:00     ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey A Law @ 1999-07-01  0:00 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Nick Clifton, binutils

  In message < 19990620164714.B4699@cygnus.com >you write:
  > >   I am not sure how this can be fixed.  I think using the hash table
  > >   may not be the best way to store global information, because of this
  > >   problem, and that another solution needs to be found.
  > 
  > My solution would be to outlaw linking together different formats,
  > and that the output format must match the input format.  Diddling
  > different formats is what objcopy is for.
I've got no problems with that.  multi-format linking was always an interesting
idea, but it never worked well and worked even less well when the linker was
changed to use native relocs instead of bfd relocs.  And I haven't seen that
multi-format linking has been all that important to the user community.

jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Where to put per-target global BFD data ?
  1999-07-01  0:00 Where to put per-target global BFD data ? Nick Clifton
@ 1999-07-01  0:00 ` Ian Lance Taylor
  1999-07-01  0:00 ` Richard Henderson
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 1999-07-01  0:00 UTC (permalink / raw)
  To: nickc; +Cc: binutils

   Date: Fri, 18 Jun 1999 10:41:18 +0100
   From: Nick Clifton <nickc@cygnus.com>

     I have come across a problem with storing target specific global
     data in BFD.  Currently targets like the ARM ports create an
     extended version of the link hash table, override the default 
     link_hash_table_create function with their own version, and then
     store their data in the new fields now available.

     This fails however, when the output format is not the same as the
     input format.  For example linking together a coff-arm object file
     with the command line:

	  ld -oformat srec foo.o

     will fail with a segmentation fault because the hash in the
     link_info structure gets created based on the output format (srec)
     not the input format (coff-arm).  The srec format does not create an
     extended structure on the end of the hash table, and so the coff-arm
     routines that get called later, and which assume that the coff-arm
     version of link_hash_table_create has been called, try to use data
     which is not there. 

     I am not sure how this can be fixed.  I think using the hash table
     may not be the best way to store global information, because of this
     problem, and that another solution needs to be found.

As you have seen, this is a general problem.  There is no way to
handle target specific information during a link to a different object
file format.  Right now, there are quite a few links which can not be
done directly to the srecord format.

If the ARM code gets a segmentation fault, that means that it is not
protecting itself correctly.  You should compare info->hash->creator
with abfd->xvec, and, if they are different, you should not assume
that the linker hash table contains ARM specific information.  You can
see quite a few examples of this in the various BFD linker
implementations.

Solving the problem in the general case is hard.  In principle, BFD
can be used to link different object file formats together.  If those
object file formats expect different global information to be stored,
then it is hard to know whether that information will be initialized
or finalized correctly.  The global information that is stored during
a link is often tied to the emulation, and if you are running a
different emulation due to a linker -m option, the wrong thing will
happen.

We might be able to fix one aspect of the problem by storing the
global information in a pointer off of the bfd_link_info structure,
and passing a pointer to that structure to the hash_table_create
function.  We would also have to create the information as it was
needed, somehow.  We could perhaps store a list of information there,
with markers to indicate which target each entry on the list was for.
Then you would have access to the global information you needed.
However, we would still need to tie the emulation code in somehow.

These are problems I unfortunately did not fully consider when I
integrated the ELF dynamic linking support.

In practice, I have simply told people that for several cases -oformat
srec unfortunately does not work, and that they must use objcopy
instead.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Where to put per-target global BFD data ?
  1999-07-01  0:00 Where to put per-target global BFD data ? Nick Clifton
  1999-07-01  0:00 ` Ian Lance Taylor
@ 1999-07-01  0:00 ` Richard Henderson
  1999-07-01  0:00   ` Jeffrey A Law
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 1999-07-01  0:00 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Fri, Jun 18, 1999 at 10:41:18AM +0100, Nick Clifton wrote:
>   This fails however, when the output format is not the same as the
>   input format.

Yep.  I have the same problem in elf64-alpha. 
My stance at this point is "Don't Do That".

>   I am not sure how this can be fixed.  I think using the hash table
>   may not be the best way to store global information, because of this
>   problem, and that another solution needs to be found.

My solution would be to outlaw linking together different formats,
and that the output format must match the input format.  Diddling
different formats is what objcopy is for.



r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-07-01  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-01  0:00 Where to put per-target global BFD data ? Nick Clifton
1999-07-01  0:00 ` Ian Lance Taylor
1999-07-01  0:00 ` Richard Henderson
1999-07-01  0:00   ` Jeffrey A Law
1999-07-01  0:00     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).