Bug 857 - Gas doesn't warn ".set x,y" when "y' is undefined
Summary: Gas doesn't warn ".set x,y" when "y' is undefined
Status: RESOLVED DUPLICATE of bug 936
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-17 14:09 UTC by H.J. Lu
Modified: 2005-05-06 18:01 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A testcase (632 bytes, application/octet-stream)
2005-04-19 17:21 UTC, H.J. Lu
Details
Test case (18.05 KB, text/plain)
2005-05-06 17:10 UTC, Joern Rennecke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2005-04-17 14:09:03 UTC
bash-3.00$ cat y.s
        .set x, y
bash-3.00$ as -o y.o y.s
bash-3.00$ readelf -s y.o

Symbol table '.symtab' contains 5 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1
     2: 00000000     0 SECTION LOCAL  DEFAULT    2
     3: 00000000     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND y
Comment 1 Alan Modra 2005-04-18 00:53:03 UTC
I don't think gas should warn in this case.  Setting a symbol to an expression
involving undefined symbols is quite a reasonable thing to do, so long as the
expression is resolved later to something that can be represented by the target
relocations.
Comment 2 H.J. Lu 2005-04-19 15:57:11 UTC
If `y' is undefined, ".set x,y" only works correctly when `x' is global.
When 'x' is local, ".set x,y" can't work right.
Comment 3 H.J. Lu 2005-04-19 17:21:37 UTC
Created attachment 460 [details]
A testcase

[hjl@gnu set-3]$ make
cc -DGOOD -shared -fPIC -o libx.so s1.c s2.c
cc -o x m.c libx.so -Wl,-rpath,.
cc -shared -fPIC -o liby.so s1.c s2.c
cc -o y m.c liby.so -Wl,-rpath,.
./x
OK: xxx calls local foo: 200
./y
BAD: xxx didn't call local foo: 0

You may have to use gcc 3.4 to compile it. The problem is

int foo ();
static int bar () __attribute__ ((alias ("foo")));

doesn't do what you want when foo is undefined.
Comment 4 H.J. Lu 2005-04-29 18:01:29 UTC
Fixed by

http://sourceware.org/ml/binutils/2005-04/msg00686.html
Comment 5 Joern Rennecke 2005-05-06 17:04:56 UTC
Your write.c patch has broken sh64-elf.
Comment 6 Joern Rennecke 2005-05-06 17:10:36 UTC
Created attachment 480 [details]
Test case

This is the newlib build failure:

/mnt/scratch/nightly/2005-05-05-sh-elf/sh64-elf/./gcc/xgcc
-B/mnt/scratch/nightly/2005-05-05-sh-elf/sh64-elf/./gcc/ -nostdinc
-B/mnt/scratch/nightly/2005-05-05-sh-elf/sh64-elf/sh64-elf/ml/newlib/ -isystem
/mnt/scratch/nightly/2005-05-05-sh-elf/sh64-elf/sh64-elf/ml/newlib/targ-include
-isystem /mnt/scratch/nightly/2005-05-05-sh-elf/srcw/newlib/libc/include
-B/usr/local/sh64-elf/bin/ -B/usr/local/sh64-elf/lib/ -isystem
/usr/local/sh64-elf/include -isystem /usr/local/sh64-elf/sys-include
-L/mnt/scratch/nightly/2005-05-05-sh-elf/sh64-elf/./ld	-ml
-DPACKAGE=\"newlib\" -DVERSION=\"1.13.0\"  -I.
-I../../../../../../srcw/newlib/libc/stdlib  -O2 -DHAVE_GETTIMEOFDAY
-fno-builtin	  -O2 -g -O2  -ml -c
../../../../../../srcw/newlib/libc/stdlib/mprec.c

real	25m36.663s
user	19m38.440s
sys	3m50.930s
/tmp/ccz68vqD.s: Assembler messages:
/tmp/ccz68vqD.s:7812: Error: Local symbol `___mprec_tens DL' can't be equated
to undefined symbol `___mprec_tens'
/tmp/ccz68vqD.s:7812: Error: Local symbol `___mprec_tens DL' can't be equated
to undefined symbol `___mprec_tens'
make[7]: *** [mprec.o] Error 1

The assembler failure can be reproduced with:
/mnt/scratch/nightly/2005-04-26-0800/sh64-elf/gas/as-new -little --isa=SHmedia
--abi=32 -o mprec.o mprec.s
mprec.s: Assembler messages:
mprec.s:7812: Error: Local symbol `___mprec_tens DL' can't be equated to
undefined symbol `___mprec_tens'
mprec.s:7812: Error: Local symbol `___mprec_tens DL' can't be equated to
undefined symbol `___mprec_tens'
Comment 7 H.J. Lu 2005-05-06 18:01:48 UTC
I opened a new bug 936.

*** This bug has been marked as a duplicate of 936 ***