提交 1da53dad 编写于 作者: R Rich Felker

disable legacy init/fini processing on ARM

since the old, poorly-thought-out musl approach to init/fini arrays on
ARM (when it was the only arch that needed them) was to put the code
in crti/crtn and have the legacy _init/_fini code run the arrays,
adding proper init/fini array support caused the arrays to get
processed twice on ARM. I'm not sure skipping legacy init/fini
processing is the best solution to the problem, but it works, and it
shouldn't break anything since the legacy init/fini system was never
used for ARM EABI.
上级 4e3c6b43
...@@ -52,3 +52,5 @@ static inline void do_single_reloc( ...@@ -52,3 +52,5 @@ static inline void do_single_reloc(
break; break;
} }
} }
#define NO_LEGACY_INITFINI
...@@ -702,8 +702,10 @@ static void do_fini() ...@@ -702,8 +702,10 @@ static void do_fini()
size_t *fn = (size_t *)(p->base + dyn[DT_FINI_ARRAY])+n; size_t *fn = (size_t *)(p->base + dyn[DT_FINI_ARRAY])+n;
while (n--) ((void (*)(void))*--fn)(); while (n--) ((void (*)(void))*--fn)();
} }
#ifndef NO_LEGACY_INITFINI
if (dyn[0] & (1<<DT_FINI)) if (dyn[0] & (1<<DT_FINI))
((void (*)(void))(p->base + dyn[DT_FINI]))(); ((void (*)(void))(p->base + dyn[DT_FINI]))();
#endif
} }
} }
...@@ -723,8 +725,10 @@ static void do_init_fini(struct dso *p) ...@@ -723,8 +725,10 @@ static void do_init_fini(struct dso *p)
p->fini_next = fini_head; p->fini_next = fini_head;
fini_head = p; fini_head = p;
} }
#ifndef NO_LEGACY_INITFINI
if (dyn[0] & (1<<DT_INIT)) if (dyn[0] & (1<<DT_INIT))
((void (*)(void))(p->base + dyn[DT_INIT]))(); ((void (*)(void))(p->base + dyn[DT_INIT]))();
#endif
if (dyn[0] & (1<<DT_INIT_ARRAY)) { if (dyn[0] & (1<<DT_INIT_ARRAY)) {
size_t n = dyn[DT_INIT_ARRAYSZ]/sizeof(size_t); size_t n = dyn[DT_INIT_ARRAYSZ]/sizeof(size_t);
size_t *fn = (void *)(p->base + dyn[DT_INIT_ARRAY]); size_t *fn = (void *)(p->base + dyn[DT_INIT_ARRAY]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册