bug-binutils
[Top][All Lists]
Advanced

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

[Bug binutils/26907] objcopy gives memsiz to segment containing empty SH


From: jozef.l at mittosystems dot com
Subject: [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section
Date: Mon, 30 Nov 2020 21:39:41 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=26907

--- Comment #6 from Jozef Lawrynowicz <jozef.l at mittosystems dot com> ---
Created attachment 13010
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13010&action=edit
pr26907-2.ld

Thanks.

However, I'm getting a similar issue with the attached linker script - an empty
SHT_NOBITS section is given its own segment.

It still looks to me like a problem that an empty output section with a wild
rule containing ".bss" is marked with SHF_ALLOC, even when it has no contents.
We can change that wild rule to anything else, including other "special
sections" which get SHF_ALLOC set automatically when they have non-zero size,
and the segment mapping comes out fine.

I was going to file a separate PR, but the crux of the problem is the same so
I'll leave it here for now.

$ as-new pr26907-2.s -o pr26907-2.o
$ ld-new pr26907-2.o -T pr26907-2.ld
$ readelf -lS pr26907-2.out

>  [ 1] .text             PROGBITS         0000000000002000  00001000
>       0000000000000000  0000000000000000  AX       0     0     1
> ...
>  [ 3] .data             PROGBITS         0000000000001000  00002000
>       0000000000000002  0000000000000000  WA       0     0     1
>  [ 4] .empty_rom        PROGBITS         0000000000002032  00002004
>       0000000000000000  0000000000000000   W       0     0     1
>  [ 5] .empty_bss_in_ram NOBITS           0000000000001002  00001002
>       0000000000000000  0000000000000000  WA       0     0     1
>  [ 6] .data2            PROGBITS         0000000000001002  00002002
>       0000000000000002  0000000000000000  WA       0     0     1

>  Program Headers:
>    Type           Offset             VirtAddr           PhysAddr
>                   FileSiz            MemSiz              Flags  Align
>    LOAD           0x0000000000000002 0x0000000000001002 0x0000000000001002
>                   0x0000000000000000 0x0000000000000000  RW     0x1000
>    LOAD           0x0000000000001000 0x0000000000002000 0x0000000000002000
>                   0x0000000000000000 0x0000000000000000  R E    0x1000
>    LOAD           0x0000000000001000 0x0000000000002000 0x0000000000002000
>                   0x0000000000000030 0x0000000000000030  R      0x1000
>    LOAD           0x0000000000002000 0x0000000000001000 0x0000000000002030
>                   0x0000000000000004 0x0000000000000004  RW     0x1000
>  ...
>   Section to Segment mapping:
>    Segment Sections...
>     00     .empty_bss_in_ram
>     01     .text
>     02     .text .note.gnu.property
>     03     .data .empty_bss_in_ram .data2
>     04     .note.gnu.property
>     05     .text .note.gnu.property

$ objcopy pr26907-2.out
> objcopy: sthKY3wa: section `.data' can't be allocated in segment 1
> LOAD: .empty_bss_in_ram .data .data2

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

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