On Tue, 9 Apr 2019 at 21:27, Rainer Orth <r...@cebitec.uni-bielefeld.de> wrote:
>
> Rainer Orth <r...@cebitec.uni-bielefeld.de> writes:
>
> > Before Solaris 11.5, struct dl_phdr_info lacked the dlpi_tls_modid
> > member.  While the support might be backported to Solaris 11.4, it
> > certainly won't to previous Solaris releases.  To work around this, I've
> > used the following patch.  Again, it's pretty straightforward.
> >
> > Point of note:
> >
> > * On Solaris, FreeBSD and NetBSD, dl_phdr_info is always visible in
> >   <link.h>, while on Linux one needs to define _GNU_SOURCE.
> >   AC_USE_SYSTEM_EXTENSION takes care of this, but needs to be called
> >   early (i.e. not in DRUNTIME_OS_DLPI_TLS_MODID) to avoid an autoconf
> >   warning:
> >
> > configure.ac:129: warning: AC_COMPILE_IFELSE was called before 
> > AC_USE_SYSTEM_EXTENSIONS
> > m4/druntime/os.m4:190: DRUNTIME_OS_DLPI_TLS_MODID is expanded from...
> > configure.ac:129: the top level
> >
> > Tested on i386-pc-solaris2.11 (Solaris 11.4) and x86_64-pc-linux-gnu.
> >
> > Not unexpectedly, there are a couple of regressions compared to the
> > Solaris 11.5/x86 results:
> >
> > +FAIL: gdc.test/runnable/testaa.d   execution test
> > +FAIL: gdc.test/runnable/testaa.d -fPIC   execution test
> > +FAIL: gdc.test/runnable/testaa.d -fPIC -shared-libphobos   execution test
> > +FAIL: gdc.test/runnable/testaa.d -shared-libphobos   execution test
> >
> >   32 and 64-bit
> >
> > +FAIL: gdc.test/runnable/xtest55.d   execution test
> > +FAIL: gdc.test/runnable/xtest55.d -shared-libphobos   execution test
> >
> >   64-bit only
> >
> > +FAIL: libphobos.shared/link_linkdep.d 
> > -I/vol/gcc/src/hg/trunk/local/libphobos/t
> > estsuite/libphobos.shared liblinkdep.so lib.so -shared-libphobos execution 
> > test
> >
> > +FAIL: libphobos.shared/load_linkdep.d -shared-libphobos -ldl execution test
> > +FAIL: libphobos.shared/load_loaddep.d -shared-libphobos -ldl execution test
> >
> > +FAIL: libphobos.shared/linkDR.c -shared-libphobos -ldl -pthread execution 
> > test
> > +FAIL: libphobos.shared/host.c -ldl -pthread execution test
> > +FAIL: libphobos.shared/loadDR.c -ldl -pthread -g execution test
> >
> >   32 and 64-bit
> >
> > +FAIL: libphobos.shared/link.d 
> > -I/vol/gcc/src/hg/trunk/local/libphobos/testsuite/libphobos.shared lib.so 
> > -shared-libphobos execution test
> >
> >   64-bit only
> >
> > I haven't looked much closer yet, just posting this to see if anything
> > along those lines could be acceptable at all.
>
> Fortunately, Iain just discovered a way better way to work around the
> lack of dlpi_tls_modid: dlinfo(RTLD_DI_LINKMAP) returns not only a
> pointer to a Link_map * as documented in the man page, but rather a
> pointer to a struct Rt_map which also includes a rt_tlsmodid member.
> It has been this way since at least Solaris 9 and the Solaris/Illumos
> sources ($SRC/cmd/sgs/include/rtld.h) explicitly have a comment around
> the start of the structure stateing
>
>         Exposed to rtld_db - don't move, don't delete
>
> which pretty much guarantees that this can be relied on.
>
> The only other quirk of note is that before dlpi_tls_modid got added,
> tlsmodid started at 0 for the main executable, not 1 as the glibc spec
> required and libdruntime assumes.  I account for this by adjusting
> _tlsMod on dlinfo and undoing the adjustment before passing it to
> __tls_get_adddr, the only consumer.
>
> With the revised patch below, I get clean gdc testresults on Solaris
> 11.3 and 11.4 (and still on 11.5 which uses the dlpi_tls_modid path),
> and almost identical libphobos testresults on all three versions.
>
> I hope this is good to go in (the sections_elf_shared.d part via
> upstream, the rest directly) now?
>
> Thanks a lot to Iain for discovering this.
>

I've finally managed to get around to moving the guts of rt.sections_*
to gcc.sections.*, with the patch amended to apply to
gcc/sections/elf_shared.d, this is OK.

-- 
Iain

Reply via email to