Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ld doesn't detect overlap with .bss

0 views
Skip to first unread message

DeanS

unread,
Apr 30, 2008, 9:33:01 AM4/30/08
to
I suspect it's always worked this way, but seems like a bug to me. I'm
using binutils 2.14 targetting powerpc (elf):

GNU ld version 2.16.91 20050610

My basic linker script is:

SECTIONS
{

.text 0x10000 :
{
c_text_start = ABSOLUTE(.);

start.o(.text)
*(.text)
*(.rodata)

c_text_end = ABSOLUTE(.);
}

.data :
{
c_data_start = ABSOLUTE(.);

*(.data);
*(.sdata);
*(.sdata2);

c_data_end = ABSOLUTE(.);
}

.bss :
{
c_bss_start = ABSOLUTE(.);

*(.bss)
*(.sbss)
*(COMMON)

c_bss_end = ABSOLUTE(.);

}

}

Which gives me (objdump):

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000216c 00010000 00010000 00000060 2**5
CONTENTS, ALLOC, LOAD, CODE
1 .data 0000002c 0001216c 0001216c 000021cc 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 000000a0 000121a0 000121a0 00002200 2**5
ALLOC
3 .stab 00003138 00000000 00000000 00002200 2**2
CONTENTS, READONLY, DEBUGGING
4 .stabstr 00003390 00000000 00000000 00005338 2**0
CONTENTS, READONLY, DEBUGGING

If I change the .data section to:

.data 0xffe0:

I get the overlap error I expect:

powerpc-ibm-eabi-ld: section .data [0000ffe0 -> 0001000b] overlaps
section .text [00010000 -> 0001216b]

However, if I change the .bss section instead:

.bss 0xffe0:

It links fine and I get:

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000216c 00010000 00010000 00000080 2**5
CONTENTS, ALLOC, LOAD, CODE
1 .data 0000002c 0001216c 0001216c 000021ec 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 000000a0 0000ffe0 0000ffe0 00000080 2**5
ALLOC
3 .stab 00003138 00000000 00000000 00002218 2**2
CONTENTS, READONLY, DEBUGGING
4 .stabstr 00003390 00000000 00000000 00005350 2**0
CONTENTS, READONLY, DEBUGGING

where .bss & .text overlap. This problem exists with other bss-like
sections as well, e.g.,

.section my_stack,"aw",@nobits

0 new messages