summaryrefslogtreecommitdiff
path: root/crt/rcrt1.c
AgeCommit message (Collapse)AuthorLines
2019-06-25remove unnecessary and problematic _Noreturn from crt/ldso startupRich Felker-2/+2
after commit a48ccc159a5fa061a18419296100ee48a1cd6cc9 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 4390383b32250a941ec616e8bff6f568a801b1c0, 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.
2018-09-05define and use internal macros for hidden visibility, weak refsRich Felker-4/+3
this cleans up what had become widespread direct inline use of "GNU C" style attributes directly in the source, and lowers the barrier to increased use of hidden visibility, which will be useful to recovering some of the efficiency lost when the protected visibility hack was dropped in commit dc2f368e565c37728b0d620380b849c3a1ddd78f, especially on archs where the PLT ABI is costly.
2016-02-18fix regression in SH/FDPIC dynamic linkerRich Felker-1/+0
the dynamic linker was found to hang when used as the PT_INTERP, but not when invoked as a command. the mechanism of this failure was not determined, but the cause is clear: commit 5552ce52000855906a5cb4f08f2e456573cca51f removed the SHARED macro, but arch/sh/crt_arch.h is still using it to choose the right form of the crt/ldso entry point code. moving the forced definition from rcrt1.c to dlstart.c restores the old behavior. eventually the logic should be changed to fully remove the SHARED macro or at least rename it to something more reasonable.
2016-01-25move dynamic linker to its own top-level directory, ldsoRich Felker-1/+1
this eliminates the last need for the SHARED macro to control how files in the src tree are compiled. the same code is used for both libc.a and libc.so, with additional code for the dynamic linker (from the new ldso tree) being added to libc.so but not libc.a. separate .o and .lo object files still exist for the src tree, but the only difference is that the .lo files are built as PIC. in the future, if/when we add dlopen support for static-linked programs, much of the code in dynlink.c may be moved back into the src tree, but properly factored into separate source files. in that case, the code in the ldso tree will be reduced to just the dynamic linker entry point, self-relocation, and loading of libraries needed by the main application.
2015-10-15fix visibility mismatch in dynamic linker stage 2 function definitionRich Felker-0/+1
since commits 2907afb8dbd4c1d34825c3c9bd2b41564baca210 and 6fc30c2493fcfedec89e45088bea87766a1e3286, __dls2 is no longer called via symbol lookup, but instead uses relative addressing that needs to be resolved at link time. on some linker versions, and/or if -Bsymbolic-functions is not used, the linker may leave behind a dynamic relocation, which is not suitable for bootstrapping the dynamic linker, if the reference to __dls2 is marked hidden but the definition is not actually hidden. correcting the definition to use hidden visibility fixes the problem. the static-PIE entry point rcrt1 was likewise affected and is also fixed by this patch.
2015-05-26add rcrt1 start file for fully static-linked PIERich Felker-0/+15
static-linked PIE files need startup code to relocate themselves, much like the dynamic linker does. rcrt1.c reuses the code in dlstart.c, stage 1 of the dynamic linker, which in turn reuses crt_arch.h, to achieve static PIE with no new code. only relative relocations are supported. existing toolchains that don't yet support static PIE directly can be repurposed by passing "-shared -Wl,-Bstatic -Wl,-Bsymbolic" instead of "-static -pie" and substituting rcrt1.o in place of crt1.o. all libraries being linked must be built as PIC/PIE; TEXTRELs are not supported at this time.