ALIGN and BLOCK in linker scripts

Paulo J. Matos pocmatos@gmail.com
Wed Jan 26 17:58:00 GMT 2011


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



More information about the Binutils mailing list