[parisc-linux] Problem with weak symbols

b.gunreben b.gunreben@web.de
Tue, 07 Jan 2003 14:05:25 +0100


Hi,

I have a problem with weak symbols on parisc. If I use the following
small program, the result should be always (nil), but it isn=B4t:

> cat weak.c
#include <stdio.h>
#include <ctype.h>
 =

asm (".weak linux_bla");
asm (".weak linux_foo");
 =

extern const char * linux_bla;
extern const int linux_foo[];
 =

int
main ()
{
  printf("linux_bla: %p\n", &linux_bla);
  printf("linux_foo: %p\n", &linux_foo);
  return 0;
}

> ./weak
linux_bla: 0x205f0
linux_foo: (nil)

The main difference in compiling seems to be the different relocation
type for both symbols:

> readelf -r weak.o
 =

Relocation section '.rela.text' at offset 0x410 contains 10 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name         =

Addend
  00000010  00502 R_PARISC_DIR21L       00000000 =

=2ELC0                      + 0
  00000014  00506 R_PARISC_DIR14R       00000000 =

=2ELC0                      + 0
  00000018  00912 R_PARISC_DPREL21L     00000000 =

linux_bla                 + 0
  0000001c  00916 R_PARISC_DPREL14R     00000000 =

linux_bla                 + 0
  00000020  00c0c R_PARISC_PCREL17F     00000000 =

printf                    + 0
  00000028  00602 R_PARISC_DIR21L       00000010 =

=2ELC1                      + 0
  0000002c  00606 R_PARISC_DIR14R       00000010 =

=2ELC1                      + 0
  00000030  00a02 R_PARISC_DIR21L       00000000 =

linux_foo                 + 0
  00000034  00a06 R_PARISC_DIR14R       00000000 =

linux_foo                 + 0
  00000038  00c0c R_PARISC_PCREL17F     00000000 =

printf                    + 0

I am currently using gcc version 3.2.1, binutils version 2.13.90.0.16
20021126, glibc version 2.3.1, but I had this problem already with gcc
3.0.4 and all compilers inbetween. Is there a possibility to work around
this?


Berthold