[libgo] Properly determine executable path on Solaris
Ian Lance Taylor
iant@golang.org
Fri Mar 1 14:21:00 GMT 2019
On Fri, Mar 1, 2019 at 2:06 AM Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>
> One of the remaining libgo testsuite failures on Solaris/SPARC is
>
> --- FAIL: TestExecutable (0.04s)
> executable_test.go:46: exec(self) failed: fork/exec .: permission denied
>
> FAIL: os
>
> This happens only for 64-bit. truss indeed shows
>
> 3181: execve(".", 0xC000170240, 0xC000178340) Err#13 EACCES
>
> which is completely bogus. Further investigation shows that
> os.Executable() returns an empty string here. I traced this down to
> go/runtime/os3_solaris.go (solarisExecutablePath) which tries to locate
> auxv from argv (I suppose the layout is prescribed by the psABIs, but
> haven't looked) and extract the AT_PAGESZ and AT_SUN_EXECNAME members.
>
> In doing so, it assumes that auxv ist just an uintptr[], which is wrong:
> <sys/auxv.h> has
>
> typedef struct
> {
> int a_type;
> union {
> long a_val;
> void *a_ptr;
> void (*a_fcn)();
> } a_un;
> } auxv_t;
>
> Interpreting this as uintptr[] works for 32-bit and accidentally on
> little-endian 64-bit (amd64), but breaks on big-endian 64-bit (sparcv9)
> as observed.
>
> While this could be corrected, there's a far easier and more portable
> way to get at the required information: AT_PAGESZ/pysPageSize can be
> obtained via getpagesize(3C) and AT_SUN_EXECNAME/executablePath is
> available via getexecname(3C), both of which are available as far back
> as Solaris 10 at least.
>
> The following patch does just that. Tested on i386-pc-solaris2.11 and
> sparc-sun-solaris2.11 (both 32 and 64-bit) without regressions, but
> fixing the os failure on sparcv9. I'm running Solaris 10 bootstraps
> right now for good measure, but don't expect any issues there.
Thanks. Committed to mainline.
Ian
More information about the Gcc-patches
mailing list