Commit Graph

662 Commits

Author SHA1 Message Date
martin 724aa133a7 Add support for sparc and sparc64 2013-07-11 06:57:15 +00:00
matt dfa5980290 Add END(func) so gdb doesn't get so confused. 2013-07-10 23:30:45 +00:00
matt 3e1a908f3c Fix another bneq -> beql botch 2013-07-10 22:55:40 +00:00
matt b32e808ac8 Add a ELFSIZE define 2013-07-10 15:05:46 +00:00
matt cf0e8a20c0 Fix logic inversion. 2013-07-10 14:27:01 +00:00
martin 14d55ae518 Try to also document the variant using common C code - Matt, please review! 2013-07-10 09:41:16 +00:00
martin 36d44ff56f Fix typo 2013-07-10 09:32:49 +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 1729cd5b7e For O32, don't save $gp on the stack, save $s0 instead and just keep $gp
in $s0.
2013-06-30 08:00:34 +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 47068b9c70 Deal with O32 callling sequences. 2013-06-25 16:51:14 +00:00
matt 83cc2631c1 Initialize $gp 2013-06-25 16:47:47 +00:00
matt a4bddaaec2 Reorder to avoid !exists
Add a crtbegin.h dependency
2013-06-25 07:18:02 +00:00
matt 86ffe64b94 Use .long not .word
Use _ENTRY
[with these changes, the crtstuff passes its ATF tests.]
2013-06-25 00:30:07 +00:00
matt 611f5afec5 Use (target1) for .init/fini array entries 2013-06-24 20:56:18 +00:00
matt e9cee35b87 Make sure dwarf_eh_object is 8 words long. 2013-06-24 14:53:42 +00:00
matt 08257f91d2 Like the rest, make __DTOR_LIST__ start with a -1
Make sure dwarf_eh_object is 8 words long.
2013-06-24 14:49:55 +00:00
matt 21ba1833d3 Make dwarf_eh_object is 8 words long 2013-06-24 14:49:13 +00:00
joerg 5b92de54be Add some more clues on what is needed to add a new platform. 2013-06-24 14:27:35 +00:00
matt 2ad451b6ca Add a common crtbegin.c file and use a machine dependent crtbegin.h to
fill in .init/.fini.
Add mips support for USE_COMPILERCRTSTUFF=no (compiled only)
2013-06-22 02:37:09 +00:00
matt 6a4f94a035 Allow crtbegin to be a C file. 2013-06-22 02:21:58 +00:00
matt be5ef6fb34 USE_COMPILERCRTSTUFF=no support for vax. 2013-06-21 15:54:08 +00:00
skrll 3defc39379 Whitespace 2013-05-05 10:26:57 +00:00
skrll dd1eb4e21c Simplify. earm is dealt with elsewhere. 2013-04-29 07:21:59 +00:00
matt 0b573b56b6 Make all earm variants use earm. 2013-04-28 06:09:52 +00:00
matt a9585fd0b1 Add support for PREINIT_ARRAY 2013-01-31 22:24:25 +00:00
matt b6b60ee9f3 Use __weakref_visible (from joerg@) 2013-01-28 16:56:39 +00:00
matt 710d6a63da Make with work with gcc 4.5 or clang. 2013-01-28 06:17:57 +00:00
matt 4855f4d98a Handle CPUFLAGS being empty 2013-01-23 02:14:14 +00:00
matt fd98dc9555 Fix static weak (to extern weak) 2013-01-22 22:57:37 +00:00
matt 552187152c If you are using aapcs, you must be using INITFINI 2013-01-22 22:49:09 +00:00
skrll 85b8a2dc6a Whitespace 2012-09-16 13:46:49 +00:00
matt 08072c6632 Fix fini processing. 2012-08-25 15:39:05 +00:00
matt 5147314742 Fix code around __register_frame_info (fixes core dumps) 2012-08-24 16:37:45 +00:00
matt 6456ecbae9 crt* files for ARM EABI. This is pretty different from OABI. crti.S only
has sysident, crtn.S is empty.  True dtor/ctor processing is done elsewhere
(in crt0.o for static or the rtld for dynamic images).  All that is done in
here is either a call to __cxa_finalize (dtor, only when SHARED) or
register_frame_info and _JV_RegisterClasses.
2012-08-13 02:49:04 +00:00
matt 6de169804e Add support for init_array/fini_array (conditionalized on HAVE_INITFINI_ARRAY).
[This is needed for ARM EABI.]
2012-08-13 02:15:35 +00:00
matt 94f921d6a9 Update copyright year. 2012-08-11 07:26:25 +00:00
matt 7f3cb3d165 Replace copyright since it now has new contents 2012-08-11 07:25:44 +00:00
matt dd044a189e Fix typo. 2012-08-11 07:25:13 +00:00
matt c135af1c81 USE_COMPILERCRTSTUFF=no support for arm
This passes all the lib/csu atf tests.
2012-08-11 01:33:36 +00:00
martin 78879908ec Slightly simplify and make position independend.
Part of fixing PR port-sparc64/46724.
2012-08-10 16:37:31 +00:00
martin cb3d712bd2 Make this position independend (for -pie executables) 2012-08-10 12:37:39 +00:00
matt cf510d3400 back out elf note changes since we can use e_flags to determine EABI usage 2012-08-05 01:44:43 +00:00
matt 36e2a4216f Use COPTS instead of CFLAGS
When compiling crti.c and crtn.c, add -DCRTI and -DCRTN, respectively.
2012-08-04 14:59:05 +00:00
matt 910686b1a1 Use CRTI instead of __S 2012-08-04 14:57:46 +00:00
matt f8fa482c66 Emit a note for EABI programs. 2012-08-03 08:01:42 +00:00
joerg c91e3eb75b Unbreak compat. 2012-06-16 19:19:14 +00:00
joerg ee99db43bc Allow USE_COMPILERCRTSTUFF=yes for platforms that use MACHINE_CPU !=
MACHINE_ARCH.
2012-06-16 18:19:39 +00:00
uwe 310c8e11f2 Claim copyright (per Joerg's request). 2012-06-02 22:15:15 +00:00
joerg 0e8643658c Don't pass assembler flags to genassym, it doesn't compile. 2012-03-25 06:55:19 +00:00
joerg 4cd46b4ac8 Add some more __dead as exposed by the recent WARN bumps. 2012-03-22 22:59:43 +00:00
he ff8e71502d Convert to use c89 function declaration. 2012-03-22 13:02:15 +00:00
matt cb0a562de5 Use __UNCONST to unconst a "" 2012-03-21 10:09:20 +00:00
uwe 4d9bf144be Implement crtbegin* for sh3. Tested to work on landisk. 2012-01-31 20:30:15 +00:00
uwe 1415c6da05 New ___start() C function takes 3 arguments instead of 6 and fetches
argc, argv and environ from ps_strings instead.  Adjust the trampoline
accordingly.

Fix brain fart in previous: direct jump is jmp @rN, not bsrf rN.
2012-01-31 20:17:57 +00:00
uwe cd23fa6d26 Use unambiguous .p2align 2 since .align 4 copied from i386 is
incorrect, as .align is .p2align on sh3, not .balign
2012-01-31 20:12:47 +00:00
uwe 5ade3e48ae Move crt0.S in front of crt0-common.c when building crt0.o and gcrt0.o.
Reading disassembly is easier when the asm crt0.S trampoline is at the
start, not hidden behind the C code in crt0-common.c.
2012-01-31 20:08:28 +00:00
uwe 1ecbaba27e Hmm, funny. I wonder why and how did emacs VC managed to add
Warning: Permanently added the RSA host key for IP address '...' to the list of known hosts.

to the committed file. (hi, new cvs!)
2012-01-31 20:03:50 +00:00
uwe cfdbe19d5f Use -DPIC to compile crtbeginS.o since that's what <machine/asm.h>
headers check.
2012-01-31 19:58:22 +00:00
uwe ffe3d8992e Since it's in a separate file now, we cannot use direct branch to label. 2012-01-29 23:27:24 +00:00
uwe 2e92e8630a Steal arch/i386/crtend.S 2012-01-28 15:08:47 +00:00
uwe 002cc93ef2 Add a comment that explains what this code does. 2012-01-28 12:44:19 +00:00
uwe 30250d8bed Asm cosmetic. Add a comment that explains what this trampoline does. 2012-01-28 12:21:13 +00:00
he 281cbfe50c After christos@ latest re-structuring of includes and defines in
the various param.h files, STACKALIGNBYTES is now called STACK_ALIGNBYTES,
so adapt accordingly.
2012-01-25 13:29:58 +00:00
mrg 74c1f8ad71 remove -I- from CPPFLAGS. 2011-10-29 10:28:37 +00:00
matt 0ac54b7e3b Don't include <machine/asm.h> 2011-07-30 15:28:58 +00:00
mrg 7c7bb760e6 revert the previous. it didn't help and wasn't the problem anyway. 2011-07-16 23:07:50 +00:00
matt 9decdbdfe4 Add missing */ 2011-07-04 21:55:09 +00:00
mrg cd21741236 XXX: for now, build sparc64 csu with -O1 if using GCC 4.5. 2011-07-04 21:54:18 +00:00
matt 532130a31c The kernel and ld.elf_so call with a different order for
cleanup, obj, ps_strings so deal with it.
With this change, USE_COMPILERCRTSTUFF=no works.
2011-07-02 20:16:09 +00:00
matt 675a57b0bb Adapt to the new ___start calling convention 2011-07-02 20:14:10 +00:00
matt fe30c1af31 Make this adhere to the SVR4 ABI. 2011-07-02 07:28:08 +00:00
joerg c4cda1a2a7 Explicitly declare ___start as hidden. 2011-07-01 02:59:05 +00:00
matt d8b68e8316 Adapt to new ___start definition.
Use PIC method to load %r13 with address of _SDA_BASE_
2011-06-30 20:10:17 +00:00
wiz 4cbd24b23f dependant -> dependent 2011-06-30 20:09:15 +00:00
matt 0d4e6aae2a Mark ___start as .hidden (for MKPIE=yes executables). 2011-06-30 20:07:35 +00:00
joerg 226567c8f9 Assert that ps_strings is valid. Use it to drop the first three
arguments to ___start to make the assembler callers simpler.
2011-06-30 19:48:43 +00:00
mrg 8f161cd6d3 remove all the code that supported HAVE_GCC=3. mostly from chuq. 2011-06-20 06:52:36 +00:00
matt 01061e574e Don't initialize %r2 for SDA2_BASE anymore. It's needed for TLS. 2011-03-12 07:56:36 +00:00
joerg 5c3ccd6eba Pass down ELF Auxillary Vectors for static NetBSD binaries too.
Rename __libc_init to _libc_init and call it explicitly from CSU code.
This enforces the constructor run order for newly linked programs.
Keep it as constructor with run-once semantic for binary compatibility.
Implement dl_iterate_phdr for statically linked programs.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
2011-03-07 05:09:09 +00:00
matt 2bf60042d7 When loading r13 and r2 with _SDA_BASE_ and _SDA2_BASE, do so in a PIC
manner.  With this change, simple programs can now run with MKPIE=yes
2011-02-26 17:11:23 +00:00
skrll 1548def5e3 Remove old hack for broken binutils. 2011-02-23 10:26:09 +00:00
joerg 9674b81ed9 Introduce __weakref_visible to handle the different required visibility
for weak references. GCC 4.2+ and Clang require static, older GCC wants
extern. Change __weak_reference to include sym. This requires changes
the existing users to not reuse the name of the symbol, but avoids
further differences between GCC 4.1 and GCC 4.2+/clang.
2011-02-22 05:45:05 +00:00
joerg 86df96f692 Allow building with the changed weakref semantic in GCC 4.2 and clang. 2011-02-18 23:37:36 +00:00
matt af25d173e6 Distinguish between a corrupt obj pointer and a null obj pointer. 2011-02-08 02:03:13 +00:00
matt 8f55cdd3bd First pass at new crtstuff for powerpc. Doesn't quite work yet
(obj parameter to ___start seems to get corrupted sometimes)
2011-02-08 02:02:25 +00:00
drochner 953846fa39 use of .PARSEDIR just doesn't work with .OBJDIR, replace with .CURDIR 2011-01-31 17:54:20 +00:00
matt b09982f7da Use uintptr_t instead of u_long.
When fetching argc use off the stack, use *(long *) instead of *(int *)
because on mips64 BE system, that int deference will only fetch 0.
2011-01-23 06:25:57 +00:00
joerg c37869d883 Build assembler sources with assembler compile rules. 2010-12-07 19:51:02 +00:00
joerg cb0b8d7cc6 Fix stack alignment for non-constructor/destructor calls.
AMD64 stack is 16 Byte aligned at the start of the function,
so always push rbx.
2010-11-30 18:37:59 +00:00
skrll 15fa0783d7 Centralise USE_COMPILERCRTSTUFF.
PCC might need help.
2010-11-28 18:40:54 +00:00
joerg fcd549e0e4 Retire old crtbegin/crtend implementation. It is not compatible with the
expectations of modern C++
2010-08-07 18:06:59 +00:00
joerg 01bc9d5012 Switch i386 and x86_64 to the new CRT layout. The crt0.c body is shared
between all platforms and a small assembler stub in crt0.S is used for
setting up the proper stack and whatever else MD needs.

Extract crti.S and crtn. from the old dot_init.h files. Prepare other
platforms that use the 6-argument form of __(_)start for this.

Rewrite the crtbegin and crtend modules in assembler to make them
compiler independent. Document the interface in README.
2010-08-07 18:01:32 +00:00
mrg 4f893703d8 delete all the a.out csu code. 2010-07-05 21:27:55 +00:00
matt 1e301281a1 Merge from matt-nb5-mips64 2009-12-14 01:00:46 +00:00
mrg 6b59d31236 move the include for <bsd.own.mk> down a little. 2009-12-13 08:52:38 +00:00
mrg cba14cb13e look for ${CSU_MACHINE_ARCH}_elf directory first. 2009-12-13 08:03:44 +00:00
skrll 7a915839ac Make lib/csu compile. XXX somewhat bogus. 2009-11-09 14:34:42 +00:00
christos ad57574aad strip .ident, if MKSTRIPIDENT. From Adam Ciarci 2009-02-18 15:21:52 +00:00
gmcgarry 3c9a95916d Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC. 2008-08-29 00:02:21 +00:00
lukem ae07e87382 Enable MAKEVERBOSE support. 2008-07-21 15:34:58 +00:00
gmcgarry 38541e9dad Remove old GCC bug work-around which relied on GCC extension. 2008-06-21 00:52:52 +00:00
mrg c2b95373bf remove clause #3 from my license where there are no other
copyright holders involved.
2008-05-29 14:51:25 +00:00
martin 5d1469bd77 Backout previous: the license sweep touched these files in error, so
restore the old license.
2008-05-10 15:31:03 +00:00
martin 3028e483e4 Convert to new 2 clause license 2008-04-29 06:53:00 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
rearnsha 00f0061ae9 ARM/Thumb interworking support 2008-03-15 10:46:24 +00:00
simonb ccab3b34ce Remove support for NetBSD/pc532. 2008-01-10 13:40:36 +00:00
skrll 587600728d Fix things so that crti.o doesn't contain a completely bogus unwind entry
that covers far too much and confuses gdb.

While here remove useless dave/restore of r4.
2007-12-02 13:55:38 +00:00
yamt c2ad33834a CLEANFILES=${OBJS} 2007-12-01 11:06:36 +00:00
yamt 82f3754f04 ___start: remove a stale comment. 2007-12-01 10:16:06 +00:00
skrll 6e57c35ead Remove an include that's not required. 2007-11-13 08:41:50 +00:00
dogcow b8d6c11ba4 <machine/profile.h> needs <sys/types.h>; why crt0.c needs <machine/profile.h>
(and only on amd64) is another question altogether.
2007-09-27 10:51:18 +00:00
skrll 795d937239 All platforms are MD_DO_NOT_NEED_FALLTHRU now so no need to keep it
conditional.
2007-05-15 16:51:37 +00:00
skrll c97173f648 MD_DO_NOT_NEED_FALLTHRU for amd64.
Thanks to Juan Romero Pardines for testing.
2007-05-15 16:48:13 +00:00
scw 5764a76889 Remove support for NetBSD/{,evb}sh5. 2007-04-08 09:35:21 +00:00
skrll bd529f8818 MD_DO_NOT_NEED_FALLTHRU for sh5. Compile tested only. 2007-03-31 21:12:37 +00:00
matt bbd7ce97e9 Didn't fix it completely. Now fixed. 2007-03-16 22:50:22 +00:00
matt 0cc8f96491 Use MD_DO_NOT_NEED_FALLTHRU 2007-03-16 22:20:50 +00:00
martin cc10b3e0c8 MD_DO_NOT_NEED_FALLTHRU - from Nick Hudson. 2007-01-02 14:32:34 +00:00
skrll 7e68cfaa21 powerpc MD_DO_NOT_NEED_FALLTHRU.
OK'ed by Matt Thomas.
2006-10-19 18:59:30 +00:00
skrll e99b876999 Alpha MD_DO_NOT_NEED_FALLTHRU
Ok'd by Matt Thomas.
2006-10-19 16:47:38 +00:00
martin 799bddf8fa MD_DO_NOT_NEED_FALLTHRU for sparc and sparc64, from Nick Hudson. 2006-10-19 08:37:46 +00:00
uwe e7b566fa33 Switch to MD_DO_NOT_NEED_FALLTHRU.
While here: Factor out .section/.previous wrapper into a separate macro.
Provide frame pointer.  Add the comment to MD_CALL_STATIC_FUNCTION to
explain why it needs semicolon and why we actually don't use that macro.
2006-10-17 01:10:26 +00:00
skrll b0b0343b24 ANSIfy 2006-09-15 05:29:44 +00:00
cherry 51b652e0e3 -DELFSIZE=64 for csu build 2006-09-14 23:55:54 +00:00
skrll 296c01bb4f MD_DO_NOT_NEED_FALLTHRU for hppa 2006-09-08 19:18:26 +00:00
skrll 61b77d1855 MD_DO_NOT_NEED_FALLTHRU for ARM. 2006-09-08 07:29:19 +00:00
skrll 44521a9e2e Implement MD_DO_NOT_NEED_FALLTHRU for i386.
Reviewed by christos.
2006-08-25 12:44:19 +00:00
skrll bc3a3e7751 Tidy up for MD_DO_NOT_NEED_FALLTHRU.
Discussed with cherry.
2006-07-18 21:18:23 +00:00
ross 7e22c74b0c Nothing from <machine/asm.h> is even used here, so don't include it.
This was the only place in the system where asm.h contents were seen
by the compiler and hence the only reason why asm.h had to conform
to C syntax. This previously limited asm.h to a cpp constructs and
comments.
2006-07-07 19:57:29 +00:00
ross ce3a138bcc add missing .globl's in new direct fallthru .init .fini 2006-07-06 22:31:55 +00:00
ross d0531274ae Conform to new world order where .init/.fini fallthru code
assembly appears directly inside _init().
2006-07-05 18:03:00 +00:00
cherry b8ee9baf67 First round at ia64 csu 2006-07-02 17:15:22 +00:00
ross 28dc42c889 fix comment 2006-07-01 01:39:17 +00:00
ross bbf630ab7c powerpc64 assembly for .init / .fini 2006-06-30 22:49:50 +00:00
simonb 842e180144 Remove the call to init_fallthru/fini_fallthru and call _init/_fini
directly for MIPS.  Making these global to keep gcc4 happy broke gcc3.
Shaves a few instructions off this path as well.

Other arches to follow with similar changes.

With much help from Nick Hudson.
2006-06-30 09:00:46 +00:00
mrg e487cf62f5 add a .globl to MD_SECTION_PROLOGUE so that the symbol is exported.
this fixes build problems with GCC4 (which will use smaller/faster call
methods for local/static functions) and is the right thing anyway.
2006-06-12 22:05:49 +00:00
mrg db19e89e04 remove support for building (with) GCC 2.95. also:
- always install <stdbool.h>
- don't generate a fake one for vax / gettext.
2006-06-02 22:16:18 +00:00
christos 351fa65664 Instead of using -I- -I${.CURDIR} and #include "dot_init.h", use:
-I${.CURDIR} and #include <dot_init.h>, since -I- is obsoleted in gcc-4,
and it is too confusing anyway.
2006-05-19 19:11:12 +00:00
christos 96473fa808 change __weak_extern to __weak_reference so that gcc4 works. 2006-05-18 17:54:19 +00:00
christos 065d43d6c4 Revert previous changes which are unnecessary now the _DYNAMIC is marked
weak.
2006-05-17 17:08:54 +00:00
christos e08e654f06 Mark _DYNAMIC to have attribute __weakref__, so that gcc-4 does not optimize
&_DYNAMIC == NULL away. From Matt Thomas.
2006-05-17 17:08:07 +00:00
christos f32828209d Back out accidental commit that changed -I- 2006-05-17 17:02:16 +00:00
christos 6f1784f6d3 Fool gcc to compare against a null variable instead of the NULL constant
so that it does not optimize the &_DYNAMIC == NULL away. Idea from Matt.
2006-05-17 17:01:12 +00:00
christos 94b00d6e09 Avoid weak symbol related bug with _DYNAMIC not being referenced in the
code at all for gcc-4. Fixes statically linked binaries, but the fix is
bogus.
2006-05-17 16:39:25 +00:00
mrg 169832563d with GCC4 we *need* to pass -fno-unit-at-a-time otherwise GCC
reorders things breaking _init() and _fini().

for i386, the {init,fini}_fallthru() functions were being output
_before_ the _init()/ _fini(), and instead of falling through to
the rest of the .init/.fini section, it would fall through to
_init()/_fini() again, and again, and again, until the stack was
exhausted.

now i386 works, but i have not checked that this works for
sparc64 as well.
2006-05-13 01:40:34 +00:00
perry 2d65de2479 bare asm -> __asm 2005-12-24 22:45:33 +00:00
perry 0db47b5ca1 bare asm -> __asm 2005-12-24 21:51:51 +00:00