public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* LTO vs. default section alignment vs. relocatable links.
@ 2011-02-01 21:19 Dave Korn
  2011-02-01 21:26 ` H.J. Lu
  2011-02-01 21:56 ` Alan Modra
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Korn @ 2011-02-01 21:19 UTC (permalink / raw)
  To: binutils


    Hi all,

  LTO IR sections need to have 1-byte alignment, and that is how we get them
from GAS.  So far so good, but when we do a -r link of two object files, the
placement of the LTO sections is handle by orphan handling, since there aren't
any LTO section output statements in any of the default linker scripts (yet).

  In practice, this leads (at least on i686-pc-cygwin) to the sections being
placed after .rodata, and they get the default section alignment.  That causes
their sizes to be rounded up to 4 with padding, which fatally confuses the
zlib decompressor in lto1 when we come to stream them back in later.

  Rather than modifying all the default linker scripts, can we handle this by
creating a synthetic output statement of some kind at LD start-up?  Or should
this be considered a weakness of orphan placement; should it notice the
alignment of the input section and create a similarly aligned orphan output
section?

    cheers,
      DaveK



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

* Re: LTO vs. default section alignment vs. relocatable links.
  2011-02-01 21:19 LTO vs. default section alignment vs. relocatable links Dave Korn
@ 2011-02-01 21:26 ` H.J. Lu
  2011-02-01 21:56 ` Alan Modra
  1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2011-02-01 21:26 UTC (permalink / raw)
  To: Dave Korn; +Cc: binutils

On Tue, Feb 1, 2011 at 1:44 PM, Dave Korn <dave.korn.cygwin@gmail.com> wrote:
>
>    Hi all,
>
>  LTO IR sections need to have 1-byte alignment, and that is how we get them
> from GAS.  So far so good, but when we do a -r link of two object files, the
> placement of the LTO sections is handle by orphan handling, since there aren't
> any LTO section output statements in any of the default linker scripts (yet).
>
>  In practice, this leads (at least on i686-pc-cygwin) to the sections being
> placed after .rodata, and they get the default section alignment.  That causes
> their sizes to be rounded up to 4 with padding, which fatally confuses the
> zlib decompressor in lto1 when we come to stream them back in later.
>
>  Rather than modifying all the default linker scripts, can we handle this by
> creating a synthetic output statement of some kind at LD start-up?  Or should
> this be considered a weakness of orphan placement; should it notice the
> alignment of the input section and create a similarly aligned orphan output
> section?

It isn't a problem on Linux. Is this a cygwin specific problem?


-- 
H.J.

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

* Re: LTO vs. default section alignment vs. relocatable links.
  2011-02-01 21:19 LTO vs. default section alignment vs. relocatable links Dave Korn
  2011-02-01 21:26 ` H.J. Lu
@ 2011-02-01 21:56 ` Alan Modra
  2011-02-01 22:27   ` Dave Korn
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Modra @ 2011-02-01 21:56 UTC (permalink / raw)
  To: Dave Korn; +Cc: binutils

On Tue, Feb 01, 2011 at 09:44:51PM +0000, Dave Korn wrote:
> 
>     Hi all,
> 
>   LTO IR sections need to have 1-byte alignment, and that is how we get them
> from GAS.  So far so good, but when we do a -r link of two object files, the
> placement of the LTO sections is handle by orphan handling, since there aren't
> any LTO section output statements in any of the default linker scripts (yet).
> 
>   In practice, this leads (at least on i686-pc-cygwin) to the sections being
> placed after .rodata, and they get the default section alignment.  That causes
> their sizes to be rounded up to 4 with padding, which fatally confuses the
> zlib decompressor in lto1 when we come to stream them back in later.

This is a PE specific problem, isnt it?

      /* All sections in an executable must be aligned to a page boundary.  */
      address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
      os = lang_insert_orphan (s, secname, constraint, after, place, address,
			       &add_child);

Fixable right there..

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: LTO vs. default section alignment vs. relocatable links.
  2011-02-01 21:56 ` Alan Modra
@ 2011-02-01 22:27   ` Dave Korn
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Korn @ 2011-02-01 22:27 UTC (permalink / raw)
  To: Dave Korn, binutils

On 01/02/2011 21:55, Alan Modra wrote:
> On Tue, Feb 01, 2011 at 09:44:51PM +0000, Dave Korn wrote:
>>     Hi all,
>>
>>   LTO IR sections need to have 1-byte alignment, and that is how we get them
>> from GAS.  So far so good, but when we do a -r link of two object files, the
>> placement of the LTO sections is handle by orphan handling, since there aren't
>> any LTO section output statements in any of the default linker scripts (yet).
>>
>>   In practice, this leads (at least on i686-pc-cygwin) to the sections being
>> placed after .rodata, and they get the default section alignment.  That causes
>> their sizes to be rounded up to 4 with padding, which fatally confuses the
>> zlib decompressor in lto1 when we come to stream them back in later.
> 
> This is a PE specific problem, isnt it?
> 
>       /* All sections in an executable must be aligned to a page boundary.  */
>       address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
>       os = lang_insert_orphan (s, secname, constraint, after, place, address,
> 			       &add_child);
> 
> Fixable right there..

  That's where I was looking, but I didn't know if ELF wouldn't also do the
same thing.  Since HJ says it doesn't, that's definitely the right place to
fix it.

    cheers,
      DaveK

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

end of thread, other threads:[~2011-02-01 22:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 21:19 LTO vs. default section alignment vs. relocatable links Dave Korn
2011-02-01 21:26 ` H.J. Lu
2011-02-01 21:56 ` Alan Modra
2011-02-01 22:27   ` Dave Korn

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).