[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/26907] New: objcopy gives memsiz to segment containing emp
From: |
jozef.l at mittosystems dot com |
Subject: |
[Bug binutils/26907] New: objcopy gives memsiz to segment containing empty SHT_NOBITS section |
Date: |
Mon, 16 Nov 2020 18:19:12 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=26907
Bug ID: 26907
Summary: objcopy gives memsiz to segment containing empty
SHT_NOBITS section
Product: binutils
Version: 2.36 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: jozef.l at mittosystems dot com
Target Milestone: ---
Created attachment 12971
--> https://sourceware.org/bugzilla/attachment.cgi?id=12971&action=edit
bss_lma_adjust.s
Consider a linker script that allows .text, .data and .bss to reside in the
same segment.
When an empty .bss section resides between non-empty .text and .data sections
in the linked output file, an objcopy of this output file adjusts the sh_offset
of the .bss section, and gives the segment containing it positive size.
The segment layout of the linked output file is:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000001000 0x0000000000000000 0x0000000000000000
0x000000000000003a 0x000000000000003a RWE 0x1000
LOAD 0x0000000000000038 0x0000000000000038 0x0000000000000038
0x0000000000000000 0x0000000000000000 RW 0x1000
Section to Segment mapping:
Segment Sections...
00 .text .note.gnu.property .bss .data
01 .bss
The two instances of the empty .bss is potentially a red flag itself.
After running objcopy, memsiz of the second segment increase from 0 to 2 bytes,
along with the aforementioned change in sh_offset.
I've attached a linker script and assembly file that reproduces the bug.
$(AS) bss_lma_adjust.s
$(LD) a.out -o before.out -T bss_lma_adjust.ld
$(OBJCOPY) before.out after.out
> objcopy: after.out: section .bss lma 0x38 adjusted to 0x3a
Note that the assignment to '.' in .bss is required to reproduce the issue (any
assignment to '.' will do).
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug binutils/26907] New: objcopy gives memsiz to segment containing empty SHT_NOBITS section,
jozef.l at mittosystems dot com <=
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/16
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/16
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/16
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, amodra at gmail dot com, 2020/11/27
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/27
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, cvs-commit at gcc dot gnu.org, 2020/11/28
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, amodra at gmail dot com, 2020/11/29
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/30
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/30
- [Bug binutils/26907] objcopy gives memsiz to segment containing empty SHT_NOBITS section, jozef.l at mittosystems dot com, 2020/11/30