On Sat, 28 Nov 2020 12:45:10 +0000 Stuart Henderson <s...@spacehopper.org> wrote:
> On 2020/11/28 12:26, helmut karlowski wrote: > > $ldd a.out > > a.out: > > Start End Type Open Ref GrpRef Name > > 1a52f000 3a537000 exe 1 0 0 a.out > > 0302c000 0302c000 ld.so 0 1 0 /usr/libexec/ld.so > > OpenBSD compilers use PIE by default, this is normal for a PIE binary. OpenBSD doesn't use ld.so for static pie. This diff might fix the problem. This diff was in one of my ports trees, but I forgot about it. The diff was from j...@bitminer.ca in "fix GCC 8.4.0 to unbreak -static linking" [1], except that this one also edits patch-gcc_config_rs6000_openbsd_h for powerpc. I forget if it works, so I will begin rechecking it. [1] https://marc.info/?l=openbsd-ports&m=159967716702259&w=2 Index: Makefile =================================================================== RCS file: /cvs/ports/lang/gcc/8/Makefile,v retrieving revision 1.36 diff -u -p -r1.36 Makefile --- Makefile 14 Nov 2020 00:00:39 -0000 1.36 +++ Makefile 30 Nov 2020 03:24:18 -0000 @@ -36,6 +36,8 @@ PKGNAME-objc = gobjc-${FULL_PKGVERSION} PKGNAME-ada = gnat-${FULL_PKGVERSION} PKGSPEC-main = gcc->=8,<9 +REVISION = 0 + SHARED_LIBS = estdc++ 19.0 \ gfortran 8.0 \ objc 8.0 \ Index: patches/patch-gcc_config_aarch64_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_aarch64_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_aarch64_openbsd_h --- patches/patch-gcc_config_aarch64_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_aarch64_openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -57,7 +57,7 @@ Index: gcc/config/aarch64/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + -L/usr/lib" + +#define OPENBSD_ENTRY_POINT "__start" Index: patches/patch-gcc_config_alpha_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_alpha_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_alpha_openbsd_h --- patches/patch-gcc_config_alpha_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_alpha_openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -2,7 +2,7 @@ $OpenBSD: patch-gcc_config_alpha_openbsd Index: gcc/config/alpha/openbsd.h --- gcc/config/alpha/openbsd.h.orig +++ gcc/config/alpha/openbsd.h -@@ -19,6 +19,28 @@ along with GCC; see the file COPYING3. If not see +@@ -19,6 +19,28 @@ along with GCC; see the file COPYING3. /* Controlling the compilation driver. */ @@ -17,7 +17,7 @@ Index: gcc/config/alpha/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC @@ -31,7 +31,7 @@ Index: gcc/config/alpha/openbsd.h /* run-time target specifications */ #define TARGET_OS_CPP_BUILTINS() \ do { \ -@@ -28,18 +50,27 @@ along with GCC; see the file COPYING3. If not see +@@ -28,18 +50,27 @@ along with GCC; see the file COPYING3. /* Layout of source language data types. */ @@ -54,9 +54,9 @@ Index: gcc/config/alpha/openbsd.h #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 -+ + +#undef WINT_TYPE +#define WINT_TYPE "int" - ++ #define LOCAL_LABEL_PREFIX "." Index: patches/patch-gcc_config_arm_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_arm_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_arm_openbsd_h --- patches/patch-gcc_config_arm_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_arm_openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -82,7 +82,7 @@ Index: gcc/config/arm/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + %{!nostdlib:-L/usr/lib}" +#endif + Index: patches/patch-gcc_config_i386_openbsdelf_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_i386_openbsdelf_h,v retrieving revision 1.3 diff -u -p -r1.3 patch-gcc_config_i386_openbsdelf_h --- patches/patch-gcc_config_i386_openbsdelf_h 8 Aug 2020 16:48:48 -0000 1.3 +++ patches/patch-gcc_config_i386_openbsdelf_h 30 Nov 2020 03:24:18 -0000 @@ -3,26 +3,29 @@ $OpenBSD: patch-gcc_config_i386_openbsde Index: gcc/config/i386/openbsdelf.h --- gcc/config/i386/openbsdelf.h.orig +++ gcc/config/i386/openbsdelf.h -@@ -97,14 +97,18 @@ along with GCC; see the file COPYING3. If not see +@@ -97,17 +97,21 @@ along with GCC; see the file COPYING3. %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}} \ + -L/usr/lib" #undef STARTFILE_SPEC --#define STARTFILE_SPEC "\ + #define STARTFILE_SPEC "\ - %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \ - crtbegin%O%s} %{shared:crtbeginS%O%s}" - -+#define SUBTARGET32_DEFAULT_CPU "i586" -+#define STARTFILE_SPEC "\ +- + %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} \ + %{!p:%{!static:crt0%O%s} %{static:%{nopie:crt0%O%s} \ + %{!nopie:rcrt0%O%s}}}} crtbegin%O%s} %{shared:crtbeginS%O%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" ++#define SUBTARGET32_DEFAULT_CPU "i586" ++ + #define OBSD_HAS_CORRECT_SPECS + + #define HAVE_ENABLE_EXECUTE_STACK Index: patches/patch-gcc_config_mips_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_mips_openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_mips_openbsd_h --- patches/patch-gcc_config_mips_openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_mips_openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -142,7 +142,7 @@ Index: gcc/config/mips/openbsd.h + %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ + %{assert*} \ -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" + +/* As an elf system, we need crtbegin/crtend stuff. */ +#undef STARTFILE_SPEC Index: patches/patch-gcc_config_pa_pa-openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_pa_pa-openbsd_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_pa_pa-openbsd_h --- patches/patch-gcc_config_pa_pa-openbsd_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_pa_pa-openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -2,14 +2,14 @@ $OpenBSD: patch-gcc_config_pa_pa-openbsd Index: gcc/config/pa/pa-openbsd.h --- gcc/config/pa/pa-openbsd.h.orig +++ gcc/config/pa/pa-openbsd.h -@@ -138,14 +138,15 @@ along with GCC; see the file COPYING3. If not see +@@ -138,14 +138,15 @@ along with GCC; see the file COPYING3. %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" #undef STARTFILE_SPEC #define STARTFILE_SPEC "\ Index: patches/patch-gcc_config_rs6000_openbsd_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_rs6000_openbsd_h,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 patch-gcc_config_rs6000_openbsd_h --- patches/patch-gcc_config_rs6000_openbsd_h 4 Jan 2019 15:50:39 -0000 1.1.1.1 +++ patches/patch-gcc_config_rs6000_openbsd_h 30 Nov 2020 03:24:18 -0000 @@ -1,7 +1,8 @@ $OpenBSD: patch-gcc_config_rs6000_openbsd_h,v 1.1.1.1 2019/01/04 15:50:39 pascal Exp $ ---- gcc/config/rs6000/openbsd.h.orig Fri Nov 15 12:47:25 2013 -+++ gcc/config/rs6000/openbsd.h Fri Nov 15 12:49:07 2013 -@@ -0,0 +1,129 @@ +Index: gcc/config/rs6000/openbsd.h +--- gcc/config/rs6000/openbsd.h.orig ++++ gcc/config/rs6000/openbsd.h +@@ -0,0 +1,131 @@ +/* Configuration file for an rs6000 OpenBSD target. + Copyright (C) 1999 Free Software Foundation, Inc. + @@ -63,12 +64,14 @@ $OpenBSD: patch-gcc_config_rs6000_openbs +#define CPP_OS_DEFAULT_SPEC "%(cpp_os_openbsd)" + +#undef LINK_SPEC -+#define LINK_SPEC "%{shared:-shared} \ -+ %{!shared: \ -+ %{!static: \ -+ %{rdynamic:-export-dynamic} \ -+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \ -+ %{static:-static}}" ++#define LINK_SPEC \ ++ "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ ++ %{shared:-shared} %{R*} \ ++ %{static:-Bstatic} \ ++ %{!static:-Bdynamic} \ ++ %{rdynamic:-export-dynamic} \ ++ %{assert*} \ ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" + +#undef LIB_DEFAULT_SPEC +#define LIB_DEFAULT_SPEC "%(lib_openbsd)" Index: patches/patch-gcc_config_sparc_openbsd64_h =================================================================== RCS file: /cvs/ports/lang/gcc/8/patches/patch-gcc_config_sparc_openbsd64_h,v retrieving revision 1.2 diff -u -p -r1.2 patch-gcc_config_sparc_openbsd64_h --- patches/patch-gcc_config_sparc_openbsd64_h 20 May 2019 14:59:05 -0000 1.2 +++ patches/patch-gcc_config_sparc_openbsd64_h 30 Nov 2020 03:24:18 -0000 @@ -2,7 +2,7 @@ $OpenBSD: patch-gcc_config_sparc_openbsd Index: gcc/config/sparc/openbsd64.h --- gcc/config/sparc/openbsd64.h.orig +++ gcc/config/sparc/openbsd64.h -@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see +@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. /* XXX - do we really want HARD_QUAD? */ #undef TARGET_DEFAULT #define TARGET_DEFAULT \ @@ -11,7 +11,7 @@ Index: gcc/config/sparc/openbsd64.h + MASK_APP_REGS + MASK_FPU + MASK_STACK_BIAS + MASK_LONG_DOUBLE_128) #undef SPARC_DEFAULT_CMODEL -@@ -30,10 +30,7 @@ along with GCC; see the file COPYING3. If not see +@@ -30,10 +30,7 @@ along with GCC; see the file COPYING3. #define TARGET_OS_CPP_BUILTINS() \ do \ { \ @@ -23,7 +23,7 @@ Index: gcc/config/sparc/openbsd64.h builtin_define ("__sparc64__"); \ builtin_define ("__sparcv9__"); \ builtin_define ("__sparc_v9__"); \ -@@ -41,14 +38,18 @@ along with GCC; see the file COPYING3. If not see +@@ -41,14 +38,18 @@ along with GCC; see the file COPYING3. } \ while (0) @@ -32,12 +32,12 @@ Index: gcc/config/sparc/openbsd64.h - #undef ASM_SPEC +#ifdef PIE_DEFAULT - #define ASM_SPEC "\ ++#define ASM_SPEC "\ +-s %{fpic|fPIC:-K PIC} %{!fno-pie: %{!p: %{!pg: -K PIC}}} \ +%(asm_cpu) %(asm_arch) \ +" +#else -+#define ASM_SPEC "\ + #define ASM_SPEC "\ -s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \ %(asm_cpu) %(asm_arch) \ " @@ -45,7 +45,7 @@ Index: gcc/config/sparc/openbsd64.h /* Layout of source language data types. */ #undef WCHAR_TYPE -@@ -57,6 +58,15 @@ along with GCC; see the file COPYING3. If not see +@@ -57,6 +58,15 @@ along with GCC; see the file COPYING3. #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 @@ -61,14 +61,14 @@ Index: gcc/config/sparc/openbsd64.h #undef LONG_DOUBLE_TYPE_SIZE #define LONG_DOUBLE_TYPE_SIZE 128 -@@ -66,13 +76,15 @@ along with GCC; see the file COPYING3. If not see +@@ -66,13 +76,15 @@ along with GCC; see the file COPYING3. %{shared:-shared} %{R*} \ %{static:-Bstatic} \ %{!static:-Bdynamic} \ + %{rdynamic:-export-dynamic} \ %{assert*} \ - -dynamic-linker /usr/libexec/ld.so" -+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}" ++ %{!shared:%{!static:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}}" /* As an elf system, we need crtbegin/crtend stuff. */ #undef STARTFILE_SPEC