public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ALIGN and BLOCK in linker scripts
@ 2011-01-21 13:50 Paulo J. Matos
  2011-01-23  3:46 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Paulo J. Matos @ 2011-01-21 13:50 UTC (permalink / raw)
  To: binutils

Hi all,

What's the different between using ALIGN and BLOCK as an optional in the 
start of an output section. For example:
"pm_region|0" BLOCK(0x4):
  {
    $pm_region.__Base = .;
    . += MAX(0x80000000, 0 + ABSOLUTE(.)) - ABSOLUTE(.);
    . = ALIGN(0x4);
    out/b85521.o*(PM_1\?$M.main)
  } > PM_REGION :PM_REGION

"pm_region|0" ALIGN(0x4):
  {
    $pm_region.__Base = .;
    . += MAX(0x80000000, 0 + ABSOLUTE(.)) - ABSOLUTE(.);
    . = ALIGN(0x4);
    out/b85521.o*(PM_1\?$M.main)
  } > PM_REGION :PM_REGION

Is there any difference between these?

For some reason without the ALIGN/BLOCK in the start of the output 
section the linking goes well, but as soon as I add it (either of them) I 
get "final link failed: File truncated".

Any tips on what might be wrong above or a way to debug why the link 
failed (--verbose says nothing)?

Cheers,
-- 
PMatos





-- 
PMatos

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

* Re: ALIGN and BLOCK in linker scripts
  2011-01-21 13:50 ALIGN and BLOCK in linker scripts Paulo J. Matos
@ 2011-01-23  3:46 ` Alan Modra
  2011-01-26 17:58   ` Paulo J. Matos
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2011-01-23  3:46 UTC (permalink / raw)
  To: Paulo J. Matos; +Cc: binutils

On Fri, Jan 21, 2011 at 01:47:47PM +0000, Paulo J. Matos wrote:
> What's the different between using ALIGN and BLOCK as an optional in the 
> start of an output section.

There is no difference between the two.

> For some reason without the ALIGN/BLOCK in the start of the output 
> section the linking goes well, but as soon as I add it (either of them) I 
> get "final link failed: File truncated".
> 
> Any tips on what might be wrong above or a way to debug why the link 
> failed (--verbose says nothing)?

You didn't tell us your target or version of ld so it's hard to give
any useful advice.  General debug techniques apply.  Find where the
error message is generated and trace back from that point..

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: ALIGN and BLOCK in linker scripts
  2011-01-23  3:46 ` Alan Modra
@ 2011-01-26 17:58   ` Paulo J. Matos
  2011-01-28  2:48     ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Paulo J. Matos @ 2011-01-26 17:58 UTC (permalink / raw)
  To: binutils

On 23/01/11 03:46, Alan Modra wrote:
> On Fri, Jan 21, 2011 at 01:47:47PM +0000, Paulo J. Matos wrote:
>> What's the different between using ALIGN and BLOCK as an optional in the
>> start of an output section.
>
> There is no difference between the two.
>

Thanks for clearing that up.

>> For some reason without the ALIGN/BLOCK in the start of the output
>> section the linking goes well, but as soon as I add it (either of them) I
>> get "final link failed: File truncated".
>>
>> Any tips on what might be wrong above or a way to debug why the link
>> failed (--verbose says nothing)?
>
> You didn't tell us your target or version of ld so it's hard to give
> any useful advice.  General debug techniques apply.  Find where the
> error message is generated and trace back from that point..
>

I have got some interest results. I am using binutils 2.17.
I have added a printf to elflink.c:9185 for loop through the 
input_bfd->sections to print the name and output_offset. Without the 
ALIGN on the output section header I get:

section .text, offset 0
section .data, offset 0
section .bss, offset 0
section PM_1?$M.main, offset 0
section DM1_1?$M.main.foo, offset 0
section PM_2?$M.main2, offset 2048
section DM1_2?$M.main2.bar, offset 7992
section PM_2?$M.main3, offset 1776
section .debug_line, offset 0
section .debug_info, offset 0
section .debug_abbrev, offset 0
section .debug_aranges, offset 0
section .debug_ranges, offset 0

with the align:

section .text, offset 0
section .data, offset 0
section .bss, offset 0
section PM_1?$M.main, offset 2147475128

That offset breaks everything onwards.

I wonder if you recall any bug that might have afflicted bfd related to 
this. I couldn't find anything on bugzilla but I don't want to track 
this down only to find it is fixed in recent versions.

Cheers,

Paulo Matos

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

* Re: ALIGN and BLOCK in linker scripts
  2011-01-26 17:58   ` Paulo J. Matos
@ 2011-01-28  2:48     ` Alan Modra
  2011-01-28 11:31       ` Paulo J. Matos
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2011-01-28  2:48 UTC (permalink / raw)
  To: Paulo J. Matos; +Cc: binutils

On Wed, Jan 26, 2011 at 05:58:30PM +0000, Paulo J. Matos wrote:
> I am using binutils 2.17.

Upgrade.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: ALIGN and BLOCK in linker scripts
  2011-01-28  2:48     ` Alan Modra
@ 2011-01-28 11:31       ` Paulo J. Matos
  0 siblings, 0 replies; 5+ messages in thread
From: Paulo J. Matos @ 2011-01-28 11:31 UTC (permalink / raw)
  To: binutils

On 28/01/11 02:48, Alan Modra wrote:
> On Wed, Jan 26, 2011 at 05:58:30PM +0000, Paulo J. Matos wrote:
>> I am using binutils 2.17.
>
> Upgrade.
>

I would if I could. It seems that having

<output section>

<output section with ALIGN(0x80) in header>

fails but

<output section>

. = ALIGN(0x80)

<output section>

works as expected...

Will leave it for now and try to upgrade as soon as possible.

Cheers,

PMatos

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

end of thread, other threads:[~2011-01-28 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21 13:50 ALIGN and BLOCK in linker scripts Paulo J. Matos
2011-01-23  3:46 ` Alan Modra
2011-01-26 17:58   ` Paulo J. Matos
2011-01-28  2:48     ` Alan Modra
2011-01-28 11:31       ` Paulo J. Matos

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