[PATCH 3/3] LoongArch: Reword message for unresolvable PC-relative relocs

Xi Ruoyao xry111@xry111.site
Wed Dec 18 09:00:01 GMT 2024


On Wed, 2024-12-18 at 16:12 +0800, Lulu Cai wrote:

/* snip */

>  Perhaps the prompt here is not always appropriate. such as: $ cat test.c
>  
> 
> 
> 
>  int a =1;
>  int main (void)
>  {
>  printf("%d\n",a);
>  }
>  
> 
> 
> 
>  $ gcc -fno-pic -c test.o
>  $ gcc -shared -o test test.o
>  
> 
> 
> 
>   Will get error message:
>  ld: test.o:(.text+0x10): relocation R_LARCH_PCALA_HI20 against `a` can not be used when making a shared object; recompile
>  with -mno-direct-extern-access and check the symbol visibility

Ah I think I've got the point.  So if we are linking a DSO, we should
still suggest -fPIC (and the compiler will reject the combination -fPIC
-mdirect-extern-access anyway so we don't need to redundantly mention -
mno-direct-extern-access); if we are linking a PIE or PDE, we should
suggest -mno-direct-extern-access.

And in both cases we should also suggest checking symbol visibility, in
addition to check compiler flags.

Is my understanding correct?


-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Binutils mailing list