-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix .cfi_undefined metadata with LLVM 16 #2202
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,12 +68,11 @@ | |
* This restriction only applies to statically linked binaries since the dynamic | ||
* linker takes care of initialization otherwise. | ||
*/ | ||
void | ||
_start(void *auxv, | ||
__dead2 static void | ||
__start(void *auxv, | ||
void (*cleanup)(void), /* from shared loader */ | ||
struct Struct_Obj_Entry *obj) /* from shared loader */ | ||
{ | ||
__asm__ volatile(".cfi_undefined c30"); | ||
int argc = 0; | ||
char **argv = NULL; | ||
char **env = NULL; | ||
|
@@ -131,3 +130,20 @@ | |
|
||
__libc_start1(argc, argv, env, cleanup, main, data_cap, code_cap); | ||
} | ||
|
||
/* | ||
* The real entry point _start just sets the unwind info for CRA to undefined | ||
* which tells libunwind to stop unwinding and then calls the real __start. | ||
* This is needed because ".cfi_undefined" inline assembly in a non-naked | ||
* function could be overridden by the default unwinding information. | ||
*/ | ||
__attribute__((naked, used)) void | ||
_start(void *auxv, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the benefit of doing this in C rather than just writing assembly? Though I continue to feel that, longer-term, we should push for some GNU attribute that allows you to eschew the assembly entirely, and can make things less stupid upstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It means I don't need to add another file to the build system. Also means we don't need to be careful about adding all the required extra directives to the .S file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm planning to upstream this to FreeBSD as well |
||
void (*cleanup)(void), /* from shared loader */ | ||
struct Struct_Obj_Entry *obj) /* from shared loader */ | ||
{ | ||
__asm__( | ||
".cfi_undefined c30\n" | ||
"bl %0" | ||
:: "i"(__start)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need the explicit
__dead2
as__libc_start1
is already tagged with that so the compiler will infer it automatically. That said, if you do keep it, I would spell this as eitherstatic void __dead2
orstatic __dead2 void
. Those are the predominate styles in the tree (a few more of the former).