bug-binutils
[Top][All Lists]
Advanced

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

as/ld silently creates programs with undefined references/symbols


From: Russell King
Subject: as/ld silently creates programs with undefined references/symbols
Date: Thu, 1 Jul 2004 17:29:51 +0100
User-agent: Mutt/1.2.5.1i

ld version:

  GNU ld version 2.14 20030612
  Copyright 2002 Free Software Foundation, Inc.
  This program is free software; you may redistribute it under the terms of
  the GNU General Public License.  This program has absolutely no warranty.

as version:

  GNU assembler 2.14 20030612
  Copyright 2002 Free Software Foundation, Inc.
  This program is free software; you may redistribute it under the terms of
  the GNU General Public License.  This program has absolutely no warranty.
  This assembler was configured for a target of `arm-linux'.

Additional patches: no.

Machine type:

  Linux 2.4.22-1.2194.nptl #1 Thu Jun 17 10:58:40 EDT 2004 i686 i686 i386 
GNU/Linux

Compiler used to build binutils:

  gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
  Copyright (C) 2003 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Command used to invoke as and ld:

  arm-linux-as -o t.o t.s
  arm-linux-ld -o t t.o --no-undefined

Object/Source file (t.s) content:

        .globl  _start
_start:
        add     r0, r0, #UNDEFINED_SYMBOL
        mov     pc, lr

Observed behaviour:

  arm-linux-as silently builds the object file.

  arm-linux-ld successfully links the 'vmlinux' object, in spite of
  arch/arm/kernel/head.o containing a reference to the undefined
  symbol "SIZEOF_MACHINE_DESC" and --no-undefined being passed on
  the linker command line.

Additional information:

  It appears that the ARM Linux 'as' incorrectly handles the case
  where an immediate constant is undefined.

  In the hope of working around this problem, I hoped that adding
  --no-undefined to the linker command line would do what it
  advertised, and fail the final link in this case.

  However, it seems that this is also doesn't work, and therefore
  it is easy to successfully create programs using the ARM Linux
  toolchain which contain undefined symbols.

  The effect of this is that it easy to create programs which build
  successfully, but are actually fundamentally wrong - it's on the
  same level as being able to successfully link a program with a
  function missing _and_ being able to run that program.

  I consider this a serious bug in binutils.

  This particular bug has also been found (by others) in the following
  versions:

    binutils 2.13.90.0.8
    GNU ld version 2.14.90.0.7 20031029 Debian GNU/Linux
    Assembleur GNU 2.15.90.0.1 20040303

  Here is a the recipe to reproduce the bug:

address@hidden bk]$ cat t.s
        .globl  _start
_start:
        add     r0, r0, #UNDEFINED_SYMBOL
        mov     pc, lr
address@hidden bk]$ arm-linux-as -o t.o t.s
address@hidden bk]$ arm-linux-nm t.o
00000000 T _start
         U UNDEFINED_SYMBOL
address@hidden bk]$ arm-linux-ld -o t t.o --no-undefined
address@hidden bk]$ arm-linux-nm t
0001007c A __bss_end__
0001007c A _bss_end__
0001007c A __bss_start
0001007c A __bss_start__
0001007c D __data_start
0001007c A _edata
0001007c A _end
0001007c A __end__
00008074 T _start
         U UNDEFINED_SYMBOL
address@hidden bk]$ arm-linux-objdump -d t
 
t:     file format elf32-littlearm
 
Disassembly of section .text:
 
00008074 <_start>:
    8074:       e2800000        add     r0, r0, #0      ; 0x0
    8078:       e1a0f00e        mov     pc, lr


-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core




reply via email to

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