mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-12 12:10:16 +00:00
elf: Assert that objects are relocated before their constructors run
If we try to run constructors before relocation, this is always a dynamic linker bug. An assert is easier to notice than a call via an invalid function pointer (which may not even produce a valid call stack). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
parent
aa70d05632
commit
7b5bfe7783
@ -16,6 +16,7 @@
|
|||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ldsodefs.h>
|
#include <ldsodefs.h>
|
||||||
#include <elf-initfini.h>
|
#include <elf-initfini.h>
|
||||||
@ -28,6 +29,11 @@ typedef void (*init_t) (int, char **, char **);
|
|||||||
static void
|
static void
|
||||||
call_init (struct link_map *l, int argc, char **argv, char **env)
|
call_init (struct link_map *l, int argc, char **argv, char **env)
|
||||||
{
|
{
|
||||||
|
/* If the object has not been relocated, this is a bug. The
|
||||||
|
function pointers are invalid in this case. (Executables do not
|
||||||
|
need relocation, and neither do proxy objects.) */
|
||||||
|
assert (l->l_real->l_relocated || l->l_real->l_type == lt_executable);
|
||||||
|
|
||||||
if (l->l_init_called)
|
if (l->l_init_called)
|
||||||
/* This object is all done. */
|
/* This object is all done. */
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user