This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: binutils-2.19.90 snapshot is available
On Sun, Sep 13, 2009 at 11:37:03AM -0400, Christopher Faylor wrote:
>On Sun, Sep 13, 2009 at 11:55:26AM +0930, Alan Modra wrote:
>>On Sat, Sep 12, 2009 at 12:41:59PM -0400, Christopher Faylor wrote:
>>> On Sat, Sep 12, 2009 at 04:26:26PM +0100, Dave Korn wrote:
>>> >Seems sane to me. It works by resetting the VMA after it's been used
>>> >in lang_size_sections_1 and the subsequent size calculations rather
>>> >than zeroing it out before these are done, yes?
>>>
>>> Yes. I tried to do the zero first and then do the size calculations
>>> using temporary values but couldn't get it quite right. I was afraid of
>>> impacting non-COFF too.
>>
>>I'm curious to know what the difference was. ELF scripts set the
>>output section vma to zero (${RELOCATING-0}) for ld -r, and we also
>>set it to zero for orphans in lang_insert_orphan. If setting to zero
>>at the beginning didn't work, then you may have a problem with
>>orphans.
>>
>>This:
>> if (link_info->relocatable)
>> os->addr_tree = exp_intop (0);
>>before the first use of addr_tree in lang_size_sections_1 ought to
>>good for all targets.
>
>The problem was that the size of the sections was still too large. I
>could have probably tried harder to find the right values to use in the
>size calculations, though.
>
>Where would you suggest that the above be added? Right before the
>switch statement in lang_size_sections_1 ?
It seems like it would only make sense in the
lang_output_section_statement_enum case so I tried the below both with
and without backing out the previous fix for PR 6945. This did reset
the VMA to zero but the sizes were still wrong (see below).
cgf
--- ldlang.c 11 Sep 2009 15:27:35 -0000 1.318
+++ ldlang.c 13 Sep 2009 15:53:59 -0000
@@ -4658,20 +4658,22 @@ lang_size_sections_1
{
switch (s->header.type)
{
case lang_output_section_statement_enum:
{
bfd_vma newdot, after;
lang_output_section_statement_type *os;
lang_memory_region_type *r;
os = &s->output_section_statement;
+ if (link_info.relocatable)
+ os->addr_tree = exp_intop (0);
if (os->addr_tree != NULL)
{
os->processed_vma = FALSE;
exp_fold_tree (os->addr_tree, bfd_abs_section_ptr, &dot);
if (expld.result.valid_p)
dot = expld.result.value + expld.result.section->vma;
else if (expld.phase != lang_mark_phase_enum)
einfo (_("%F%S: non constant or forward reference"
" address expression for section %s\n"),
# segm.o is the original, segm1.o is the ld -r'ed object
bash-3.2$ size segm.o segm1.o
text data bss dec hex filename
128 256 0 384 180 segm.o
512 384 400 1296 510 /tmp/segm1.o
bash-3.2$ objdump -h segm.o /tmp/segm1.o
segm.o: file format pe-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000070 00000000 00000000 000000b4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000100 00000000 00000000 00000124 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000000 2**2
ALLOC
3 .rdata 00000010 00000000 00000000 00000224 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
segm1.o: file format pe-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000070 00000000 00000000 000000b4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000180 00000000 00000000 00000124 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .rdata 00000190 00000000 00000000 000002a4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .bss 00000190 00000000 00000000 00000000 2**2
ALLOC