Message ID | 87lhvjhl6e.fsf@kepler.schwinge.homeip.net |
---|---|
State | New |
Headers | show |
On 04/05/2014 05:04 PM, Thomas Schwinge wrote: > Is it a linker bug that I need to add something like the following? > > --- libgcc/ompstuff.c > +++ libgcc/ompstuff.c > @@ -40,6 +40,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > #include "libgcc_tm.h" > > #if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) > +# if 1 > +/* TODO: Without the following, will get missing symbols for __start_* and > + __stop_*. Linker bug? */ > +static void *_funcs[0] __attribute__ ((section ("__gnu_offload_funcs"))) = { }; > +static void *_vars[0] __attribute__ ((section ("__gnu_offload_vars"))) = { }; > +# endif Things seemed to work over here, but now I'm not certain whether the __start_/__stop_ functionality is GNU ld specific? Maybe we should just go back to the previous version of this patch which didn't try to use this. Bernd
On Sat, Apr 05, 2014 at 05:22:09PM +0200, Bernd Schmidt wrote: > On 04/05/2014 05:04 PM, Thomas Schwinge wrote: > >Is it a linker bug that I need to add something like the following? > > > >--- libgcc/ompstuff.c > >+++ libgcc/ompstuff.c > >@@ -40,6 +40,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > > #include "libgcc_tm.h" > > > > #if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) > >+# if 1 > >+/* TODO: Without the following, will get missing symbols for __start_* and > >+ __stop_*. Linker bug? */ > >+static void *_funcs[0] __attribute__ ((section ("__gnu_offload_funcs"))) = { }; > >+static void *_vars[0] __attribute__ ((section ("__gnu_offload_vars"))) = { }; > >+# endif > > Things seemed to work over here, but now I'm not certain whether the > __start_/__stop_ functionality is GNU ld specific? Maybe we should > just go back to the previous version of this patch which didn't try > to use this. Somebody needs to try it with gold, I think it should support the same. As for other linkers, don't we need linker plugin support anyway, which is not available for other linkers? Jakub
On 05 Apr 17:22, Bernd Schmidt wrote: > Things seemed to work over here, but now I'm not certain whether the > __start_/__stop_ functionality is GNU ld specific? Maybe we should > just go back to the previous version of this patch which didn't try > to use this. > > Bernd This approach does not work with shared libraries. The automatically inserted symbols have GLOBAL binding, therefore the __start_/__stop_ from the executable overwrite the respective symbols in DSO. Here is a simple example with 2 DSOs and one executable. The function GOMP_offload_register is called with the following pointers in HOST_TABLE: 1. (funcs 0x604880:0x604898, vars 0x604840:0x604880) 2. (funcs 0x604880:0x604898, vars 0x604840:0x604880) 3. (funcs 0x604880:0x604898, vars 0x604840:0x604880) But with "manually" added start/stop and LOCAL binding everything works fine: 1. (funcs 0x7f286b425530:0x7f286b425540, vars 0x7f286b425540:0x7f286b425540) 2. (funcs 0x7f286b8624a0:0x7f286b8624b0, vars 0x7f286b8624b0:0x7f286b8624b0) 3. (funcs 0x604760:0x604778, vars 0x604780:0x6047c0) -- Ilya
--- libgcc/ompstuff.c +++ libgcc/ompstuff.c @@ -40,6 +40,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "libgcc_tm.h" #if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING) +# if 1 +/* TODO: Without the following, will get missing symbols for __start_* and + __stop_*. Linker bug? */ +static void *_funcs[0] __attribute__ ((section ("__gnu_offload_funcs"))) = { }; +static void *_vars[0] __attribute__ ((section ("__gnu_offload_vars"))) = { }; +# endif extern void __start___gnu_offload_funcs; extern void __stop___gnu_offload_funcs; extern void __start___gnu_offload_vars;