Print this page
crt: Need a position-independent CRT for PIE
- Implement the greatest possible part of the crt1 in C
- Implement SPARC versions of the ASM sections of crt1
- Build crt1 position-independently, minor ASM updates to be position
  independent
- Implement crt1 with the hook expected by modern GCC to support
  profiling, make gcrt1 a symlink for source compatibility (older GCC
  initializes profiling at firsnt use of _mcount if necessary, so
  doesn't need the gcrt)
- Split the CRT out of developer/library/lint into a separate c-runtime package

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/i386/gen/makectxt.c
          +++ new/usr/src/lib/libc/i386/gen/makectxt.c
↓ open down ↓ 48 lines elided ↑ open up ↑
  49   49   * aligned before a function call (STACK_ALIGN == 4).  The ABI supplement
  50   50   * version 1.0 changed the required alignment to 16-byte for the benefit of
  51   51   * floating point code compiled using sse2.  The compiler assumes this
  52   52   * alignment and maintains it for calls it generates.  If the stack is
  53   53   * initially properly aligned, it will continue to be so aligned.  If it is
  54   54   * not initially so aligned, it will never become so aligned.
  55   55   *
  56   56   * One slightly confusing detail to keep in mind is that the 16-byte
  57   57   * alignment (%esp & 0xf == 0) is true just *before* the call instruction.
  58   58   * The call instruction will then push a return value, decrementing %esp by
  59      - * 4.  Therefore, if one dumps %esp at the at the very first instruction in
       59 + * 4.  Therefore, if one dumps %esp at the very first instruction in
  60   60   * a function, it will end with a 0xc.  The compiler expects this and
  61   61   * compensates for it properly.
  62   62   *
  63   63   * Note: If you change this value, you need to change it in the following
  64   64   * files as well:
  65   65   *
  66   66   *  - lib/libc/i386/threads/machdep.c
  67      - *  - lib/common/i386/crti.s
  68      - *  - lib/common/i386/crt1.s
       67 + *  - lib/crt/i86/crti.s
       68 + *  - lib/crt/i86/crt1.s
  69   69   */
  70   70  #undef  STACK_ALIGN
  71   71  #define STACK_ALIGN     16
  72   72  
  73   73  static void resumecontext(void);
  74   74  
  75   75  void
  76   76  makecontext(ucontext_t *ucp, void (*func)(), int argc, ...)
  77   77  {
  78   78          long *sp;
↓ open down ↓ 40 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX