Skip to content

Commit 54b7564

Browse files
committed
remove unnecessary and problematic _Noreturn from crt/ldso startup
after commit a48ccc1 removed the use of _Noreturn on the stage3_func type (which only worked due to it being defined to the "GNU C" attribute in C99 mode), GCC could no longer assume that the ends of __dls2 and __dls2b are unreachable, and produced a warning that a function marked _Noreturn returns. also, since commit 4390383, the _Noreturn declaration for __libc_start_main in crt1/rcrt1 has been not only inconsistent with the definition, but wrong. formally, __libc_start_main does return, via a (hopefully) tail call to a helper function after the barrier. incorrect usage of _Noreturn in the declaration was probably formal UB. the _Noreturn specifiers were not useful in any of these places, so remove them all. now, the only remaining usage of _Noreturn is in public interfaces where _Noreturn is part of their contract.
1 parent 95dfa3d commit 54b7564

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

crt/crt1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
int main();
99
weak void _init();
1010
weak void _fini();
11-
_Noreturn int __libc_start_main(int (*)(), int, char **,
11+
int __libc_start_main(int (*)(), int, char **,
1212
void (*)(), void(*)(), void(*)());
1313

1414
void _start_c(long *p)

crt/rcrt1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
int main();
66
weak void _init();
77
weak void _fini();
8-
_Noreturn int __libc_start_main(int (*)(), int, char **,
8+
int __libc_start_main(int (*)(), int, char **,
99
void (*)(), void(*)(), void(*)());
1010

11-
hidden _Noreturn void __dls2(unsigned char *base, size_t *sp)
11+
hidden void __dls2(unsigned char *base, size_t *sp)
1212
{
1313
__libc_start_main(main, *sp, (void *)(sp+1), _init, _fini, 0);
1414
}

ldso/dynlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ hidden void __dls2(unsigned char *base, size_t *sp)
16441644
* so that loads of the thread pointer and &errno can be pure/const and
16451645
* thereby hoistable. */
16461646

1647-
_Noreturn void __dls2b(size_t *sp)
1647+
void __dls2b(size_t *sp)
16481648
{
16491649
/* Setup early thread pointer in builtin_tls for ldso/libc itself to
16501650
* use during dynamic linking. If possible it will also serve as the
@@ -1665,7 +1665,7 @@ _Noreturn void __dls2b(size_t *sp)
16651665
* process dependencies and relocations for the main application and
16661666
* transfer control to its entry point. */
16671667

1668-
_Noreturn void __dls3(size_t *sp)
1668+
void __dls3(size_t *sp)
16691669
{
16701670
static struct dso app, vdso;
16711671
size_t aux[AUX_CNT], *auxv;

0 commit comments

Comments
 (0)