Page MenuHomeFreeBSD

D48700.id150050.diff
No OneTemporary

D48700.id150050.diff

diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c
--- a/lib/csu/common/crtbegin.c
+++ b/lib/csu/common/crtbegin.c
@@ -66,19 +66,27 @@
(crt_func)-1
};
+extern const char startof_dtors[] __asm(".startof..dtors")
+ __weak_symbol __hidden;
+extern const char sizeof_dtors[] __asm(".sizeof..dtors")
+ __weak_symbol __hidden;
+
static void
__do_global_dtors_aux(void)
{
crt_func fn;
+ uintptr_t dtors_end;
int n;
#ifdef SHARED
run_cxa_finalize();
#endif
+ dtors_end = (uintptr_t)&startof_dtors + (uintptr_t)&sizeof_dtors;
for (n = 1;; n++) {
fn = __DTOR_LIST__[n];
- if (fn == (crt_func)0 || fn == (crt_func)-1)
+ if (fn == (crt_func)0 || fn == (crt_func)-1 || (dtors_end > 0 &&
+ (uintptr_t)&__DTOR_LIST__[n] >= dtors_end))
break;
fn();
}
diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c
--- a/lib/csu/common/crtend.c
+++ b/lib/csu/common/crtend.c
@@ -21,7 +21,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#include <sys/types.h>
#include "crt.h"
typedef void (*crt_func)(void);
@@ -45,15 +45,22 @@
(crt_func)0
};
+extern const char startof_ctors[] __asm(".startof..ctors")
+ __weak_symbol __hidden;
+
static void
__do_global_ctors_aux(void)
{
crt_func fn;
+ uintptr_t ctors_start;
int n;
+ ctors_start = (uintptr_t)&startof_ctors;
for (n = 1;; n++) {
fn = __CTOR_END__[-n];
- if (fn == (crt_func)0 || fn == (crt_func)-1)
+ if (fn == (crt_func)0 || fn == (crt_func)-1 ||
+ (ctors_start > 0 &&
+ (uintptr_t)&__CTOR_END__[-n] < ctors_start))
break;
fn();
}

File Metadata

Mime Type
text/plain
Expires
Thu, May 1, 9:55 PM (11 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17891448
Default Alt Text
D48700.id150050.diff (1 KB)

Event Timeline