Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 18 Jul 2013 22:17:26 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: New "portable" crt1.c

Hi all,

I've been experimenting with an idea for eliminating most of the asm
from the "crt" start files. The basic concept is to have a tiny
file-scope __asm__ statement, pulled in from arch/$(ARCH)/crt1.h or
similar, which does nothing but calling a portable C version of
_start, contained in crt1.c, with the right arguments.

The benefits:
- We get regular (crt1.o) and PIE (Scrt1.o) versions for free.
- Porting to new archs is simpler.
- Applying the same technique to crti.o/crtn.o, we can support the
  new-style init_array/fini_array on all archs without lots of new
  per-arch asm.

Attached is a demo for i386 showing how well this approach works (size
increase is less than 16 bytes).

I'm open to comments, but my feeling is that we should keep the
existing crt asm for archs where it already exists, but replace the
empty crt1.c with a version based on this approach, and encourage
using the new approach on all new ports. In the future, if maintaining
the current asm becomes a burden (e.g. if new requirements are
introduced) we could remove the existing asm and switch to the C for
all ports.

Rich

View attachment "newcrt.c" of type "text/plain" (622 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.