This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Powerpc64 does not generate copy relocation for shared library variable

Hi All,
consider below scenario
$cat shared.c
int var=10;
$ccppc -shared -fpic shared.c -o
$cat test.c
extern int var;
int main(){
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

       /* 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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]