[GOLD] powerpc DT_RELACOUNT
authorAlan Modra <amodra@gmail.com>
Thu, 22 Jun 2023 23:18:38 +0000 (08:48 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 23 Jun 2023 11:32:48 +0000 (21:02 +0930)
DT_RELACOUNT was calculated incorrectly, and relative relocs not
sorted as they should be to the start of .rela.dyn, due to adding one
particular class of dynamic reloc using the wrong "add" method.

* powerpc.cc (Target_powerpc::Scan::global): Add relative
dyn relocs for ADDR64 and similar using add_global_relative.

gold/powerpc.cc

index aa2d9a187874f3856fa827ba0bf8cbd524637f1a..0c15e1b37212619c0ff87da2eda9d86207a87869 100644 (file)
@@ -9005,9 +9005,14 @@ Target_powerpc<size, big_endian>::Scan::global(
                  = target->rela_dyn_section(symtab, layout, is_ifunc);
                unsigned int dynrel = (is_ifunc ? elfcpp::R_POWERPC_IRELATIVE
                                       : elfcpp::R_POWERPC_RELATIVE);
-               rela_dyn->add_symbolless_global_addend(
+               // Use the "add" method that marks the reloc as being
+               // relative.  This is proper here and in other places
+               // that add IRELATIVE relocs because those relocs go
+               // into a separate section that isn't sorted, so it
+               // doesn't matter that they are marked is_relative.
+               rela_dyn->add_global_relative(
                    gsym, dynrel, output_section, object, data_shndx,
-                   reloc.get_r_offset(), reloc.get_r_addend());
+                   reloc.get_r_offset(), reloc.get_r_addend(), false);
              }
            else
              {