Powerpc64 does not generate copy relocation for shared library variable
kamlesh kumar
kamleshbhalui@gmail.com
Tue Jul 30 03:53:00 GMT 2019
Hi All,
consider below scenario
$cat shared.c
int var=10;
$ccppc -shared -fpic shared.c -o libshared.so
$cat test.c
#include<stdio.h>
extern int var;
int main(){
var++;
printf("%d",var);
return 0;}
$ccppc -L. -lshared test.c
$ nmppc ./a.out | grep var
U var
which is referring to var which is defined in a shared library, while it
should do copy relocation.
$ccppc --version
ccppc 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
While looking into elf64-ppc.c found that below patch solve the problem.
After applying below patch it does copy relocation for shared library
variable var.
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 5be3fe0..6d07e9b 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -6125,7 +6125,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info
*info,
/* If we don't find any dynamic relocs in read-only sections, then
we'll be keeping the dynamic relocs and avoiding the copy reloc.
*/
- || (ELIMINATE_COPY_RELOCS && !alias_readonly_dynrelocs (h))
+// || (ELIMINATE_COPY_RELOCS ) && !alias_readonly_dynrelocs (h))
/* Protected variables do not work with .dynbss. The copy in
.dynbss won't be used by the shared library with the protected
Like to know your insight before going ahead?
./Kamlesh
More information about the Binutils
mailing list