All of lore.kernel.org
 help / color / mirror / Atom feed
* [parisc-linux] hppa glibc ld -r
@ 2000-08-17  7:59 Alan Modra
  2000-08-17 15:23 ` H . J . Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2000-08-17  7:59 UTC (permalink / raw)
  To: libc-alpha; +Cc: parisc-linux, parisc

Hello glibc experts,
  I've hit a snag trying to build a shared hppa glibc with my latest
linker, and I think the only solution is to get rid of the "ld -r" stage
in building glibc.

For those on the list reading this not familiar with the details of
elf32-hppa linking:  PA has a limited range for pc-relative branches, and
the linker needs to insert long branch stubs to reach far off locations.
Long branch stubs (and other stub types) are placed in a special stub
section preceding every linker input section.  If input sections are too
big, we can't even reach the stubs, so using gcc -ffunction-sections helps
to stop "ld -r" packing all the code into one huge .text section.

-ffunction-sections isn't a complete solution though.  If two source files
declare a local function of the same name, "setup", for instance, then
both files will have a section called ".text.setup".  These two sections
will be merged during the "ld -r", which has the unfortunate effect of
moving a local function to a location a long way off from where it's
called.  That's bad, firstly because it means we now need a stub to reach
the function, but more importantly the stubs are not PIC and thus need
relocation information when creating shared libraries.  In particular, for
reasons too complicated to explain here, I don't want to create stubs for
local functions;  It would mean emitting relocs for every *potential*
stub.

Anybody know why glibc uses "ld -r", and if there is a good reason why
we can't just remove the "ld -r"?

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.

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

* Re: hppa glibc ld -r
  2000-08-17  7:59 [parisc-linux] hppa glibc ld -r Alan Modra
@ 2000-08-17 15:23 ` H . J . Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H . J . Lu @ 2000-08-17 15:23 UTC (permalink / raw)
  To: Alan Modra; +Cc: libc-alpha, parisc-linux, parisc

On Thu, Aug 17, 2000 at 05:59:48PM +1000, Alan Modra wrote:
> 
> -ffunction-sections isn't a complete solution though.  If two source files
> declare a local function of the same name, "setup", for instance, then
> both files will have a section called ".text.setup".  These two sections
> will be merged during the "ld -r", which has the unfortunate effect of

Can you teach ld not to merge ".text.xxxxx" with -r under HPPA?

> moving a local function to a location a long way off from where it's
> called.  That's bad, firstly because it means we now need a stub to reach
> the function, but more importantly the stubs are not PIC and thus need
> relocation information when creating shared libraries.  In particular, for
> reasons too complicated to explain here, I don't want to create stubs for
> local functions;  It would mean emitting relocs for every *potential*
> stub.
> 
> Anybody know why glibc uses "ld -r", and if there is a good reason why
> we can't just remove the "ld -r"?

I don't think it has to be used. --whole-archive will do the same
trick. But "ld -r" is more convenient. With --whole-archive, you may
have to put -Wl,--whole-archive/-Wl,--no-whole-archive around each file
generarted with "ld -r"


H.J.

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

end of thread, other threads:[~2000-08-17 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-08-17  7:59 [parisc-linux] hppa glibc ld -r Alan Modra
2000-08-17 15:23 ` H . J . Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.