From d80593bc4d4381331453d96d03c11d70247e2d70 Mon Sep 17 00:00:00 2001 From: seyko Date: Sun, 29 Mar 2015 11:28:02 +0300 Subject: fix for the bcheck.o (bug #14958) - care about __attribute__ redefinition in the system headers - an invalid pointer must be returned when (addr >= e->size), and not (addr > e->size) A test program: #include #include int main () { int v[10]; fprintf(stderr, "&v[0] = %p\n", &v[0]); fprintf(stderr, "&v[10] = %p\n", &v[10]); exit(1); return 0; } // tcc -b test.c The output before a patch: &v[0] = 0xbf929d8c &v[10] = 0xbf929db4 The output after a patch: &v[0] = 0xbff6e33c &v[10] = 0xfffffffe --- tccelf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tccelf.c') diff --git a/tccelf.c b/tccelf.c index 0ac151a..494bc0a 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1577,7 +1577,7 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1) return; /* XXX: add an object file to do that */ - ptr = section_ptr_add(bounds_section, sizeof(unsigned long)); + ptr = section_ptr_add(bounds_section, sizeof(*ptr)); *ptr = 0; add_elf_sym(symtab_section, 0, 0, ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, -- cgit v1.3.1