bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/20280] New: gold output is different from ld when LMA is set


From: phosek at google dot com
Subject: [Bug gold/20280] New: gold output is different from ld when LMA is set
Date: Mon, 20 Jun 2016 22:47:02 +0000

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

            Bug ID: 20280
           Summary: gold output is different from ld when LMA is set
           Product: binutils
           Version: 2.27 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: phosek at google dot com
                CC: ian at airs dot com
  Target Milestone: ---

I found a difference in behavior between gold and ld when LMA is set for a
section but not for subsequent sections. See the example below:

---
$ cat test.S
.section .text
  nop
.section .data
  .long 123

$ cat test.ld
SECTIONS
{
  .text : AT(0x1000000) { *(.text) }
  .data : { *(.data) }
}

$ as test.S -o test.o

$ ld.bfd test.o -T test.ld -o test-bfd

$ readelf -lW test-bfd

Elf file type is EXEC (Executable file)
Entry point 0x0
There are 1 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz
  Flg Align
  LOAD           0x200000 0x0000000000000000 0x0000000001000000 0x000005
0x000005 RWE 0x200000

 Section to Segment mapping:
  Segment Sections...
   00     .text .data

$ ld.gold test.o -T test.ld -o test-gold

$ readelf -lW test-gold

Elf file type is EXEC (Executable file)
Entry point 0x0
There are 2 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz
  Flg Align
  LOAD           0x001020 0x0000000000000020 0x0000000000000020 0x000004
0x000004 RW  0x1000
  LOAD           0x002000 0x0000000000000000 0x0000000001000000 0x000001
0x000001 R E 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .data 
   01     .text
---

The important bit is the difference between the .data section physical address
in case of ld and gold. Seems like ld reuses the existing memory region (the
one used for .text section), for the .data section while gold believes that
there is no suitable region for the .data section and sets its LMA to the VMA.

-- 
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]