diff options
| author | grischka <grischka> | 2009-04-18 13:14:07 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2009-04-18 15:08:03 +0200 |
| commit | 73ba078d2f703ab991ddc36b3504d96f35466700 (patch) | |
| tree | 192cfe0d96aa462b62bc5254a29ff177ce9da87b /tcc.c | |
| parent | d36fea34e36c7effc36592b214a2ff69fb97e844 (diff) | |
| download | tinycc-73ba078d2f703ab991ddc36b3504d96f35466700.tar.gz tinycc-73ba078d2f703ab991ddc36b3504d96f35466700.tar.bz2 | |
tcc_relocate: return error and remove unused code
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 23 |
1 files changed, 5 insertions, 18 deletions
@@ -10315,9 +10315,9 @@ int tcc_relocate(TCCState *s1, void *ptr) unsigned long offset, length, mem; int i; - s1->nb_errors = 0; - if (0 == s1->runtime_added) { + s1->runtime_added = 1; + s1->nb_errors = 0; #ifdef TCC_TARGET_PE pe_add_runtime(s1); relocate_common_syms(); @@ -10328,28 +10328,15 @@ int tcc_relocate(TCCState *s1, void *ptr) tcc_add_linker_symbols(s1); build_got_entries(s1); #endif - s1->runtime_added = 1; } - offset = 0; - mem = (unsigned long)ptr; + offset = 0, mem = (unsigned long)ptr; for(i = 1; i < s1->nb_sections; i++) { s = s1->sections[i]; if (0 == (s->sh_flags & SHF_ALLOC)) continue; length = s->data_offset; - if (0 == mem) { - s->sh_addr = 0; - } else if (1 == mem) { - /* section are relocated in place. - We also alloc the bss space */ - if (s->sh_type == SHT_NOBITS) - s->data = tcc_malloc(length); - s->sh_addr = (unsigned long)s->data; - } else { - /* sections are relocated to new memory */ - s->sh_addr = (mem + offset + 15) & ~15; - } + s->sh_addr = mem ? (mem + offset + 15) & ~15 : 0; offset = (offset + length + 15) & ~15; } @@ -10385,7 +10372,7 @@ int tcc_relocate(TCCState *s1, void *ptr) ptr = (void*)s->sh_addr; if (NULL == s->data || s->sh_type == SHT_NOBITS) memset(ptr, 0, length); - else if (ptr != s->data) + else memcpy(ptr, s->data, length); /* mark executable sections as executable in memory */ if (s->sh_flags & SHF_EXECINSTR) |
