[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/948] Wrong LMA for section with empty input section.

From: fabrice_gautier at sdesigns dot com
Subject: [Bug ld/948] Wrong LMA for section with empty input section.
Date: 16 May 2005 20:44:55 -0000

------- Additional Comments From fabrice_gautier at sdesigns dot com  
2005-05-16 20:44 -------
(In reply to comment #2)
> I can't reproduce it with binutils in CVS nor the Linux binutils

Actually you did reproduce it just there ...

> I got
> address@hidden empty-7]$ make
> ./ld -o x -T script.ld test-lma.o
> ./objdump -h x
> x:     file format elf32-i386
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .text         0000002d  20000000  00000000  00001000  2**2
>   1 .data         00000004  40000000  00001000  00002000  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>   2 .rodata       0000000c  40000004  40000004  00002004  2**0

Right Here -----------------------------^^^^^^^^

This should be (I believe): LMA=00001004  not LMA=VMA=40000004

>                   CONTENTS

>   3 .bss          00000004  40000010  00001010  00002004  2**2
>                   ALLOC
>   4 .comment      00000032  00000000  00000000  00002010  2**0
>                   CONTENTS, READONLY
> address@hidden empty-7]$ ./objcopy -O binary x x.bin
> address@hidden empty-7]$ ls -l x.bin
> -rwxrwxr-x  1 hjl hjl 4100 May 16 11:48 x.bin
This is odd though.... Where did the rodata section go in this binary ??

I was testing with binutils 2.15 btw, I build a 2.16, and although the results
are a bit different I still think there is a bug, I'm not just sure what is the
bug but I can see that, with 2.16:

* The .rodata section doesnt have the LOAD flag. So doing an "objcopy -O binary
-j .rodata rodata.bin" will return an empty file.
*But .rodata has a section size non null
*But (unlike with 2.15) there is some space in the elf file reserverd for the
content of .rodata. (Easy to see by increasing the .=ALIGN(16) to .=ALIGN(256))
*But the content of .rodata is all zeroes even if we add a FILL expression in
the script. (objdump -Dz -j .rodata a.out will show that)

So I'm not sure exactly how this is supposed to work but I see three (related) 
- LMA is wrong
- LOAD is not set
- FILL expression is not used

You my just want to say that this is expected behaviour because the .rodata
section is considered an empty section, but then I would report two bug:
- Size of an empty section is not null.
- Space is wasted in the elf file for an empty section.

In any case, my original intent in creating this linker script with the
.=ALIGN(16) in the .rodata section was to ensure that the size of my binary
image after objcopy would be a multiple of 16. Works fine except when there is
nothing in the input .rodata sections.

I'm reopening the bug. If you think that the current behaviour is the correct
one then please close again.

Thank you

-- Fabrice

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]