csu: Add .note.ABI-tag and .note.GNU-stack
authorJohn Marino <draco@marino.st>
Mon, 23 Jan 2012 00:21:15 +0000 (01:21 +0100)
committerJohn Marino <draco@marino.st>
Mon, 23 Jan 2012 16:13:18 +0000 (17:13 +0100)
commitf4df877297f500e9a39a8d96275c2520079d6e40
tree5a7117b209567199618779db62d7902fb739eb0d
parent565fefef27d4ee677dfea0cc9390ae5bd5da5bb1
csu: Add .note.ABI-tag and .note.GNU-stack

For all arches except sparc, gcc emits the section directive for the
following struct with a PROGBITS type.  However, newer versions of binutils
(after 2.16.90) require the section to be of NOTE type, to guarantee that
the .note.ABI-tag section correctly ends up in the first page of the final
executable.

Unfortunately, there is no clean way to tell gcc to use another section
type, so this C file (or the C file that includes it) must be compiled in
multiple steps:

- Compile the .c file to a .s file.
- Edit the .s file to change the 'progbits' type to 'note', for the section
  directive that defines the .note.ABI-tag section.
- Compile the .s file to an object file.

These steps are done in the invididual Makefiles for each applicable arch.

Taken-from: FreeBSD SVN 217375 (13 JAN 2011)

On i386 crtn.S:
Keep the stack aligned to a 16 byte boundary when calling init functions
so that we don't cause a bus error if they start storing SSE math stuff
on the stack.

Taken-from: FreeBSD SVN 146369 (19 MAY 2005)
lib/csu/common/crtbrand.c
lib/csu/i386/Makefile.csu
lib/csu/i386/crt1_s.S
lib/csu/i386/crti.S
lib/csu/i386/crtn.S
lib/csu/x86_64/Makefile.csu
lib/csu/x86_64/crti.S
lib/csu/x86_64/crtn.S