https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577

--- Comment #198 from Peter Bisroev <peter.bisroev at groundlabs dot com> ---
(In reply to dave.anglin from comment #196)
> If you create a second object file with a second instance of hello, the
> linker should not
> complain about the second definition of hello since it is weak.  It would
> complain about
> two global instances.
Hi Dave,

I have created a new object hello2.o, and when I tried to link I got
------------------------------
"ld: Duplicate symbol "hello" in files hello.o and hello2.o "
------------------------------
Then I realized that in hello.s hello is defined as ".global hello". Changing
that to '.weak hello', reassembling and relinking all worked. I guess this
confirms what I have seen in comment 187. So this seems to work as expected.
This worked both with aCC and gcc.

> Could you test whether the "brl" branch works?  Simply take your main.s file
> and edit the branch
> to hello.  This should show whether the assembler can handle it.  If it
> assembles, look at relocation
> and see if program will link.
I took main.s generated by aCC. Made the following changes:
------------------------------
$ diff main-aCC.s main-aCC-weak-brl.s 
7c7
<       .global hello
---
>       .weak   hello
41c41
<         br.call.dptk.many rp = hello#           ;; // B [main.cc: 10/5]
---
>         brl.call.dptk.many rp = hello#           ;; // B [main.cc: 10/5]
------------------------------

Reassembled with HP's as, relinked and the test ran fine. With this change when
hello was global PCREL21B relocation was used. When I changed hello to weak,
PCREL21B was still used. When I changed this to weak with a brl, PCREL60B was
used.


I have then tried to do a similar thing with main.s generated by gcc. 
------------------------------
$ diff main-gcc.s main-gcc-brl.s 
19c19
<       br.call.sptk.many b0 = hello#
---
>       brl.call.sptk.many b0 = hello#
------------------------------

Reassembled with GNU's as and relinked. PCREL21B changes to PCREL60B, but when
I try to run the binary I get an "Illegal instruction" and a core dump. The
illegal instruction seems to be the brl. I know almost nothing of IA-64
assembly, so will read up a bit more and try to figure out what is going on
there.

Please let me know if I have missed anything.

Thanks!
--peter

Reply via email to