Commit Graph

71 Commits

Author SHA1 Message Date
christos
7a3b8449d8 Re-do previous (always make available preinit/initarray/finiarray), with
less disruption.
2018-12-28 20:12:35 +00:00
christos
12faa81882 Undo previous; breaks macppc/m68k (at least) 2018-12-28 18:17:10 +00:00
christos
96e2e1e315 Avoid duplicate definitions on arm (reported by kre@) 2018-12-28 13:53:17 +00:00
christos
7848d457d8 Allow both array and non-array constructors for transition. 2018-12-27 19:32:32 +00:00
christos
312d62b9b5 Enable initfini array support for everyone. 2018-12-27 18:57:14 +00:00
joerg
463db15fc5 Do not pass the main object handle from the assembler startup stub to
the common ___start routine. It's only used for a pointless magic
version check. Thanks to martin@ for testing various architectures.
2018-11-26 17:37:44 +00:00
kre
96ef5eaedd i386/amd64 build fix. Fix "possibly used uninitialized" from gcc.
These changes should make no practical effect - but because external
data is being examined, it would be possible to contrive a situation
(perhaps) where uninit'd vars could actually be used (unless the format
has been checked elsewhere earlier - I did not look ... we have to
appease gcc anyway).

Joerg: Please review (& fix)
2018-07-13 01:00:17 +00:00
joerg
26c47810f2 Add static PIE support for i386 and AMD64.
The basic glue works with mininal changes for other architectures as
well, but those require linker changes first to avoid leaking dynamic
relocations into the binary.
2018-07-12 21:36:45 +00:00
joerg
c0d91a1260 _DYNAMIC is present for static PIE as well, so loosen rtld check. 2018-07-12 21:35:12 +00:00
joerg
2d65afd272 Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.
2018-03-29 13:23:39 +00:00
joerg
a64ef2fb9e Add ifunc support for statically linked applications on x86, ppc, sparc
and ARM.
2018-03-09 20:20:47 +00:00
joerg
b373b9e517 .eh_frame should be read-only on MIPS too. 2017-07-18 14:34:19 +00:00
joerg
b16a977791 For some mind-boogling reasons, GCC 5.4 believes that a weak reference
cannot alias with an extern. While this is clearly bogus, avoid yet
another alias handling bug and use strong aliases. It's actually
slightly simpler, too.
2016-06-29 11:16:47 +00:00
joerg
6da05bfa8e Fun fact of the weak: a weak reference doesn't have visibility attached.
As such, reorganize the start/end references to use a weak reference
only, if we use it to remove size knowledge. Otherwise use weak
external declarations.
2016-06-07 12:07:35 +00:00
joerg
70b825c3b6 Make older GCC and Clang happy and use weak references to the elements,
not declared as arrays.
2016-06-05 00:43:39 +00:00
joerg
b940261f81 Revert -O1 hack for GCC 5.3, replaced by workaround in the code. 2016-06-01 21:24:55 +00:00
joerg
ad68895fdb PR toolchain/51121:
__CTOR_LIST__ and __CTOR_LIST_END__ are logically the same object, but
due to the start marker, the former has to be declared as array of fixed
size. Newer GCC versions take the liberty of exploiting the UB of
accessing global objects past the end to unconditionally load zero
values in that case. Two fixes are possible:
(1) Pruning via inline assembler as done by GCC's own CRT copy.
(2) Pruning via weak references as done for linker sets.
Since the second part is known and required to work anyway, prefer this
approach. In theory, the labels could be replaced completely, except
that GNU as doesn't provide start/end symbols for sections containing
dots.
2016-06-01 21:21:55 +00:00
martin
f5d70023d1 We need the -O1 hack (for gcc 5.3) for crtbegin.c as well.
Works around PR toolchain/51121.
2016-05-10 10:23:09 +00:00
martin
8e6585046e Change section flags to "MG" and put it into comdat.
Makes new binutils happy.
2016-05-01 08:33:14 +00:00
martin
92f3e401cd Revert previous (fallout is more subtle but there).
Rework the conditionon so it depends on .S existence instead of an arch
list.
2016-05-01 07:25:46 +00:00
martin
318ac55504 Gcc 5.3 seems to do fine compiling this for sparc64, so exclude it
from the -O1 hack
2016-04-30 13:12:13 +00:00
martin
53a4b022d2 For the benefit of compilers not using our native C runtime environment,
install a "sysident.o" file providing the note identifying NetBSD
executables (and marking the currently installed version).
2016-04-04 18:29:07 +00:00
skrll
e4a98f388f crt0-common.c is miscompiled by gcc 5.3 on evbarm with -O2 so use -O1. Do
this for all non-x86 arches.
2016-03-29 21:23:05 +00:00
mrg
09a7b9833f add a hack for GCC 5 and non-x86 platforms:
build crtbeginS.o with -O1 as GCC tries to be very smart with the
__DTOR_LIST__ as it believes it knows the size of the array at
compile time (which is not true until link time).  on SPARC and
MIPS, the result was emitting a call to 0.

technically, i believe that GCC isn't "wrong" to make this choice,
as the array is declared with a well-known initialiser size in the
crtbegin.c compilation unit, and we have noticed that the libgcc
version of this code has some hacks added, most likely to avoid
being bitten by this optimisation.


this makes sshd work for me on earm and sparc with GCC 5.
2016-03-27 00:03:06 +00:00
joerg
88fc449bba Ensure notes are properly padded to 32bit length. 2014-05-14 14:59:14 +00:00
joerg
353aedd819 Make EHABI optional. 2014-05-06 16:02:10 +00:00
joerg
6ccf4859e4 Add GENASSYM_CPPFLAGS in two more places. 2014-03-04 17:57:56 +00:00
martin
fb526759de Make the .note section mergable and set proper "item" length.
XXX seems to be impossible to do that with gas w/o causing a (bogus)
warning - but the resulting object file is fine.
2014-02-26 14:54:50 +00:00
bouyer
0a181232be Also make sure the __CTOR_LIST__ is just aligned to a pointer boundary.
By default, mips N32 will aligned to a 64-bit boundary not 32-bit
which causes an extra NULL entry to be added.
Fix "segfault on exit" several people have noticed on mips N32,
caused by a jr to a NULL address.
2014-01-29 20:57:49 +00:00
matt
383316f200 Using ${LD} -x screws up BE arm. Use ${OBJCOPY} ${OBJCOPYLIBFLAGS} instead
so the $a/$t/$d symbols are preserved.
2014-01-11 00:18:15 +00:00
matt
7118e2b334 Make sure the __CTOR_LIST__ is just aligned to a pointer boundary.
By default, mips N32 will aligned to a 64-bit boundary not 32-bit
which causes an extra NULL entry to be added.
2013-12-11 06:55:24 +00:00
joerg
cd32ef253c Include crtbegin.h first to make it possible to build with the stricter
attribute consistency checks in clang.
2013-11-29 23:00:48 +00:00
martin
44525f39e0 Simplify previous by using CSU_MACHINE_ARCH. Hint from Takeshi Nakayama. 2013-11-17 11:16:09 +00:00
martin
3fb362f863 We do not want to build the code model markes when creating the 32bit
compat libs for sparc64
2013-11-16 10:50:43 +00:00
martin
591a8c0745 On sparc64: create additional "marker" object files, that can be used by the
compiler to encode the used code model in binaries.
2013-11-14 12:19:34 +00:00
joerg
f0495d06b6 Explicitly depend on sys/param.h to pick up __NetBSD_Version changes. 2013-11-11 10:24:27 +00:00
uwe
f09e72233a Fix previous: use PICFLAGS for crtbeginS.o
Should unbreak sh3 builds.

XXX: PICFLAGS is defined in bsd.lib.mk which lib/csu does not use.
For now supply a local definition.  joerg@, please fix appropriately.
2013-09-18 22:53:39 +00:00
joerg
4d12bfcd15 Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
2013-09-12 15:36:14 +00:00
matt
988e1b8be5 MARCH note is conditional 2013-09-10 17:23:55 +00:00
matt
b4939ef9a5 Add support for a NetBSD MARCH elf note to record the MACHINE_ARCH for
which a program was compiled.
2013-09-10 16:45:33 +00:00
matt
704e1f2829 MIPS wants a read/write eh_frame. 2013-08-26 14:20:53 +00:00
matt
c1007461a4 Put the ctors code in .text.startup and dtors code in .text.exit 2013-08-19 22:15:13 +00:00
matt
64e75f2480 Alpha needs crtfm.o for USE_COMPILERCRTSTUFF=no 2013-08-05 13:38:35 +00:00
matt
75eb6b3ee8 Only supplie -fPIE to crtbegin.c if MKPIC is yes. 2013-07-18 18:43:56 +00:00
martin
3f349243f2 Use -fPIE for crtbegin.o (instead of -fpie).
Fixes linking the firefox js shell. Ok: joerg@
2013-07-17 14:23:45 +00:00
joerg
c4d240b19a Only install crtbeginS.o, crtbeginT.o and crtendS.o when MKPIC=yes. 2013-07-05 02:06:49 +00:00
matt
350cb9bc6c Switch arm, earm, powerpc to use crtbegin.c
Use -fpie for crtbegin.
2013-06-27 21:24:39 +00:00
matt
2943b5ff66 Add -fPIC to compile of crtbeginS.o 2013-06-27 03:37:21 +00:00
matt
a4bddaaec2 Reorder to avoid !exists
Add a crtbegin.h dependency
2013-06-25 07:18:02 +00:00
matt
21ba1833d3 Make dwarf_eh_object is 8 words long 2013-06-24 14:49:13 +00:00