aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-30 11:19:12 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-30 11:19:12 +0100
commitf089ef880e385e2193237b1f53ec81dac4141680 (patch)
treeb690e3b29e050765da1478c045d2622eb5097655 /libgcc
parentcd107c1603ad5e030ee1001ec244e4d0d3f0b79b (diff)
downloadgcc-f089ef880e385e2193237b1f53ec81dac4141680.zip
gcc-f089ef880e385e2193237b1f53ec81dac4141680.tar.gz
gcc-f089ef880e385e2193237b1f53ec81dac4141680.tar.bz2
openmp: Add crtoffloadtableS.o and use it [PR117851]
Unlike crtoffload{begin,end}.o which just define some symbols at the start/end of the various .gnu.offload* sections, crtoffloadtable.o contains const void *const __OFFLOAD_TABLE__[] __attribute__ ((__visibility__ ("hidden"))) = { &__offload_func_table, &__offload_funcs_end, &__offload_var_table, &__offload_vars_end, &__offload_ind_func_table, &__offload_ind_funcs_end, }; The problem is that linking this into PIEs or shared libraries doesn't work when it is compiled without -fpic/-fpie - __OFFLOAD_TABLE__ for non-PIC code is put into .rodata section, but it really needs relocations, so for PIC it should go into .data.rel.ro/.data.rel.ro.local. As I think we don't want .data.rel.ro section in non-PIE binaries, this patch follows the path of e.g. crtbegin.o vs. crtbeginS.o and adds crtoffloadtableS.o next to crtoffloadtable.o, where crtoffloadtableS.o is compiled with -fpic. 2024-11-30 Jakub Jelinek <jakub@redhat.com> PR libgomp/117851 gcc/ * lto-wrapper.cc (find_crtoffloadtable): Add PIE_OR_SHARED argument, search for crtoffloadtableS.o rather than crtoffloadtable.o if true. (run_gcc): Add pie_or_shared variable. If OPT_pie or OPT_shared or OPT_static_pie is seen, set pie_or_shared to true, if OPT_no_pie is seen, set pie_or_shared to false. Pass it to find_crtoffloadtable. libgcc/ * configure.ac (extra_parts): Add crtoffloadtableS.o. * Makefile.in (crtoffloadtableS$(objext)): New goal. * configure: Regenerated.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/Makefile.in3
-rwxr-xr-xlibgcc/configure3
-rw-r--r--libgcc/configure.ac3
3 files changed, 7 insertions, 2 deletions
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index ffc45f2..c50a537 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -1064,6 +1064,9 @@ crtoffloadend$(objext): $(srcdir)/offloadstuff.c
crtoffloadtable$(objext): $(srcdir)/offloadstuff.c
$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_TABLE
+
+crtoffloadtableS$(objext): $(srcdir)/offloadstuff.c
+ $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_TABLE
endif
ifeq ($(enable_vtable_verify),yes)
diff --git a/libgcc/configure b/libgcc/configure
index 15a0be2..1841833 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -5295,7 +5295,8 @@ fi
if test x"$enable_offload_targets" != x; then
- extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o crtoffloadtable.o"
+ extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o"
+ extra_parts="${extra_parts} crtoffloadtable.o crtoffloadtableS.o"
fi
# Check if Solaris/x86 linker supports ZERO terminator unwind entries.
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index ca34147..85e4f1b 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -481,7 +481,8 @@ AC_SUBST(accel_dir_suffix)
AC_SUBST(real_host_noncanonical)
if test x"$enable_offload_targets" != x; then
- extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o crtoffloadtable.o"
+ extra_parts="${extra_parts} crtoffloadbegin.o crtoffloadend.o"
+ extra_parts="${extra_parts} crtoffloadtable.o crtoffloadtableS.o"
fi
# Check if Solaris/x86 linker supports ZERO terminator unwind entries.