Force the dynamic linker to resolve _end early so we pick up the correct

copy.

Sponsored by:	ABT Systems Ltd
This commit is contained in:
Andrew Turner 2015-07-02 15:02:59 +00:00
parent 74735cf188
commit b339ef955c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285044

View File

@ -51,6 +51,8 @@ extern int eprol;
extern int etext;
#endif
extern long * _end;
void __start(int, char **, char **, void (*)(void));
/* The entry function. */
@ -79,8 +81,17 @@ __start(int argc, char *argv[], char *env[], void (*cleanup)(void))
if (&_DYNAMIC != NULL)
atexit(cleanup);
else
else {
/*
* Hack to resolve _end so we read the correct symbol.
* Without this it will resolve to the copy in the library
* that firsts requests it. We should fix the toolchain,
* however this is is needed until this can take place.
*/
*(volatile long *)&_end;
_init_tls();
}
#ifdef GCRT
atexit(_mcleanup);