ARM: calls to undefined weak symbols

Christian Groessler chris@groessler.org
Wed Mar 2 13:08:00 GMT 2016


Hi,

it just occurred to me: couldn't calls to undefined weak symbols 
completely be removed
instead of being replaced by a 'nop' (when doing a 'relaxing' link)?

-----
$ cat weak.s
         .text
         .align  2
         .weak fred
         .global _start
_start:
         sub     r0,r1,r2
         bl fred
         add     r0,r1,r2
$ arm-linux-gnueabi-as -o weak.o weak.s
$ arm-linux-gnueabi-ld --relax -o weak.elf weak.o
$ arm-linux-gnueabi-objdump -d weak.elf

weak.elf:     file format elf32-littlearm


Disassembly of section .text:

00010054 <_start>:
    10054:       e0410002        sub     r0, r1, r2
    10058:       e1a00000        nop                     ; (mov r0, r0)
    1005c:       e0810002        add     r0, r1, r2
$
-----

Are there technical reasons for not doing this? Or is it just that 
nobody implemented it?

regards,
chris



More information about the Binutils mailing list