bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/458] New: Subtracting two relative symbols in a section produces


From: e9925248 at stud4 dot tuwien dot ac dot at
Subject: [Bug ld/458] New: Subtracting two relative symbols in a section produces a relative symbol
Date: 18 Oct 2004 08:05:14 -0000

If two relative symbols are subtracted in a linker script, the linker adds the 
start address of the section to the result. 
 
An example: 
$cat t.s 
        .section .text 
db:     .byte 0x12 
$cat t.link 
SECTIONS { 
. = 0x10; 
.text ALIGN(0x1) : { 
_text_start = . ; 
        *(.data) 
        *(.text) 
_text_end = . ; 
_text_size = _text_end - _text_start ; 
} 
.test : { 
SHORT(_text_size) 
SHORT(_text_start) 
SHORT(_text_end) 
SHORT(_text_end - _text_start) 
} 
} 
$binutils/gas/as-new -o t.o t.s 
$binutils/ld/ld-new -T t.link -M -o to t.o 
 
Memory Configuration 
 
Name             Origin             Length             Attributes 
*default*        0x00000000         0xffffffff 
 
Linker script and memory map 
 
                0x00000010                . = 0x10 
 
.text           0x00000010        0x1 
                0x00000010                _text_start = . 
 *(.data) 
 *(.text) 
 .text          0x00000010        0x1 t.o 
                0x00000011                _text_end = . 
                0x00000011                _text_size = (_text_end - 
_text_start) 
 
.test           0x00000011        0x8 
                0x00000011        0x2 SHORT 0x11 _text_size 
                0x00000013        0x2 SHORT 0x10 _text_start 
                0x00000015        0x2 SHORT 0x11 _text_end 
                0x00000017        0x2 SHORT 0x1 (_text_end - _text_start) 
 
.bss            0x0000001c        0x0 
LOAD t.o 
OUTPUT(to elf32-i386) 
$binutils/ld/ld-new -v 
GNU ld version 2.15.93 20041018 
 
In the debugger _text_size is created in fold_binary in ldexp.c with the right 
value, but the section is not changed, so the result is 0x11. 
 
Older version of ld (eg. GNU ld version 2.13.90.0.18 20030121 Debian GNU/Linux) 
create _text_size with an value of 0x01. 
 
Martin Kögler 
address@hidden

-- 
           Summary: Subtracting two relative symbols in a section produces a
                    relative symbol
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: e9925248 at stud4 dot tuwien dot ac dot at
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-linux-gnu (but not i686 spezific)
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=458

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