ANY_INIT_TO_ANY_EXIT,
ANY_EXIT_TO_ANY_INIT,
EXPORT_TO_INIT_EXIT,
+ DATA_TO_TEXT
};
struct sectioncheck {
.tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
.mismatch = EXPORT_TO_INIT_EXIT,
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
+},
+/* Do not reference code from writable data */
+{
+ .fromsec = { DATA_SECTIONS, NULL },
+ .tosec = { TEXT_SECTIONS, NULL },
+ .mismatch = DATA_TO_TEXT
}
};
continue;
if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
continue;
- if (sym->st_value == addr)
- return sym;
/* Find a symbol nearby - addr are maybe negative */
d = sym->st_value - addr;
+ if (d == 0)
+ return sym;
if (d < 0)
d = addr - sym->st_value;
if (d < distance) {
tosym, prl_to, prl_to, tosym);
free(prl_to);
break;
+ case DATA_TO_TEXT:
+#if 0
+ fprintf(stderr,
+ "The %s %s:%s references\n"
+ "the %s %s:%s%s\n",
+ from, fromsec, fromsym, to, tosec, tosym, to_p);
+#endif
+ break;
}
fprintf(stderr, "\n");
}
static void check_sec_ref(struct module *mod, const char *modname,
struct elf_info *elf)
{
- int i;
+ unsigned int i;
Elf_Shdr *sechdrs = elf->sechdrs;
/* Walk through all sections */
va_end(ap);
}
-void buf_write(struct buffer *buf, const char *s, int len)
+void buf_write(struct buffer *buf, const char *s, unsigned int len)
{
if (buf->size - buf->pos < len) {
buf->size += len + SZ;
if (fstat(fileno(file), &st) < 0)
goto close_write;
- if (st.st_size != b->pos)
+ if (st.st_size != (off_t)b->pos)
goto close_write;
tmp = NOFAIL(malloc(b->pos));