|
Message-ID: <CAOUYtQAeJvx2a6Gb8NW-64UGC7E=8N7C+LC9nvv_oBnQ4bAEOg@mail.gmail.com>
Date: Sun, 26 Aug 2018 01:56:30 +0100
From: Jon Chesterfield <jonathanchesterfield@...il.com>
To: musl@...ts.openwall.com
Subject: [PATCH] _start_c does more work than is necessary
The init sequence in musl is _start calls _start_c which calls
__libc_start_main.
_start_c passes pointers to the _init and _fini functions, and also a
trailing zero, to __libc_start_main.
__libc_start_main currently takes exactly three arguments. I'd like to
simplify crt1.c by only passing main, argc, argv.
This is worth a few lines of C and three instructions in the startup
sequence. E.g. x86-64 this removes mov, mov, xor for fourteen bytes.
It also removes uses of _init() and _free() which I'm considering deleting
from a musl/llvm toolchain which makes no use of either, slightly
decreasing the size of my out of tree patch.
Thanks,
Jon
---
diff --git a/crt/crt1.c b/crt/crt1.c
index af02af9..f27c949 100644
--- a/crt/crt1.c
+++ b/crt/crt1.c
@@ -5,14 +5,11 @@
#include "crt_arch.h"
int main();
-void _init() __attribute__((weak));
-void _fini() __attribute__((weak));
-_Noreturn int __libc_start_main(int (*)(), int, char **,
- void (*)(), void(*)(), void(*)());
+_Noreturn int __libc_start_main(int (*)(), int, char **);
void _start_c(long *p)
{
int argc = p[0];
char **argv = (void *)(p+1);
- __libc_start_main(main, argc, argv, _init, _fini, 0);
+ __libc_start_main(main, argc, argv);
}
Content of type "text/html" skipped
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.