Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    f089ef88
    openmp: Add crtoffloadtableS.o and use it [PR117851] · f089ef88
    Jakub Jelinek authored
    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.
    f089ef88
    History
    openmp: Add crtoffloadtableS.o and use it [PR117851]
    Jakub Jelinek authored
    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.