OSDN Git Service

fix malloc misuse for startup ctor queue, breakage on fdpic archs
authorRich Felker <dalias@aerifal.cx>
Sun, 3 Mar 2019 14:57:19 +0000 (09:57 -0500)
committerRich Felker <dalias@aerifal.cx>
Sun, 3 Mar 2019 17:06:44 +0000 (12:06 -0500)
commit2f1f51ae7b2d78247568e7fdb8462f3c19e469a4
tree8aba33ec7fe11fb172bf9e715edfc4841600b405
parent8e43b5613eea0b557a2e91368917a90f4b0e4ab2
fix malloc misuse for startup ctor queue, breakage on fdpic archs

in the case where malloc is being replaced, it's not valid to call
malloc between final relocations and main app's crt1 entry point; on
fdpic archs the main app's entry point will not yet have performed the
self-fixups necessary to call its code.

to fix, reorder queue_ctors before final relocations. an alternative
solution would be doing the allocation from __libc_start_init, after
the entry point but before any ctors run. this is less desirable,
since it would leave a call to malloc that might be provided by the
application happening at startup when doing so can be easily avoided.
ldso/dynlink.c