Message ID | ca9c2cfd0f0d09eb65e8dffe971cc62511d32d60.1692701787.git.fweimer@redhat.com |
---|---|
State | New |
Headers | show |
Series | Predictable ELF destructor ordering (bug 30785) | expand |
On Aug 22 2023, Florian Weimer via Libc-alpha wrote: > diff --git a/elf/dl-init.c b/elf/dl-init.c > index 5b0732590f..fefd471851 100644 > --- a/elf/dl-init.c > +++ b/elf/dl-init.c > @@ -25,6 +25,10 @@ > static void > call_init (struct link_map *l, int argc, char **argv, char **env) > { > + /* Do not run constructors for proxy objects. */ > + if (l != l->l_real) > + return; > + > /* 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.) */ Now that we know that l == l->l_real, the following assertion does not need to indirect through l_real any more.
* Andreas Schwab: > On Aug 22 2023, Florian Weimer via Libc-alpha wrote: > >> diff --git a/elf/dl-init.c b/elf/dl-init.c >> index 5b0732590f..fefd471851 100644 >> --- a/elf/dl-init.c >> +++ b/elf/dl-init.c >> @@ -25,6 +25,10 @@ >> static void >> call_init (struct link_map *l, int argc, char **argv, char **env) >> { >> + /* Do not run constructors for proxy objects. */ >> + if (l != l->l_real) >> + return; >> + >> /* 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.) */ > > Now that we know that l == l->l_real, the following assertion does not > need to indirect through l_real any more. Thanks, makes sense. Okay to push with that change? @@ -25,10 +25,14 @@ static void call_init (struct link_map *l, int argc, char **argv, char **env) { + /* Do not run constructors for proxy objects. */ + if (l != l->l_real) + return; + /* 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); + assert (l->l_relocated || l->l_type == lt_executable); if (l->l_init_called) /* This object is all done. */ Florian
On Aug 22 2023, Florian Weimer wrote: > @@ -25,10 +25,14 @@ > static void > call_init (struct link_map *l, int argc, char **argv, char **env) > { > + /* Do not run constructors for proxy objects. */ > + if (l != l->l_real) > + return; > + > /* 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); > + assert (l->l_relocated || l->l_type == lt_executable); The reference to proxy objects in the second comment is obsolete as well. Ok with that change.
diff --git a/elf/dl-init.c b/elf/dl-init.c index 5b0732590f..fefd471851 100644 --- a/elf/dl-init.c +++ b/elf/dl-init.c @@ -25,6 +25,10 @@ static void call_init (struct link_map *l, int argc, char **argv, char **env) { + /* Do not run constructors for proxy objects. */ + if (l != l->l_real) + return; + /* 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.) */