fix for: x86_64-tcc compiled by i386-tcc is wrong
A test program (must be compiled by the above version of the tcc):
/* Tickle a bug in TinyC on 64-bit systems:
* the LSB of the top word or ARGP gets set
* for no obvious reason.
*
* Source: a legacy language interpreter which
* has a little stack / stack pointer for arguments.
*
* Output is: 0x8049620 0x10804961c
* Should be: 0x8049620 0x804961c
*/
#include <stdio.h>
#define NARGS 20000
int ARG[NARGS];
int *ARGSPACE = ARG;
int *ARGP = ARG - 1;
main() { printf("%p %p\n", ARGSPACE, ARGP); }
This commit is contained in:
2
libtcc.c
2
libtcc.c
@ -540,7 +540,7 @@ ST_FUNC void put_extern_sym(Sym *sym, Section *section,
|
|||||||
|
|
||||||
/* add a new relocation entry to symbol 'sym' in section 's' */
|
/* add a new relocation entry to symbol 'sym' in section 's' */
|
||||||
ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type,
|
ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type,
|
||||||
unsigned long addend)
|
addr_t addend)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
if (sym) {
|
if (sym) {
|
||||||
|
|||||||
4
tcc.h
4
tcc.h
@ -1095,7 +1095,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name);
|
|||||||
ST_FUNC void put_extern_sym2(Sym *sym, Section *section, addr_t value, unsigned long size, int can_add_underscore);
|
ST_FUNC void put_extern_sym2(Sym *sym, Section *section, addr_t value, unsigned long size, int can_add_underscore);
|
||||||
ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
|
ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
|
||||||
ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
|
ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
|
||||||
ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, unsigned long addend);
|
ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
|
||||||
|
|
||||||
ST_INLN void sym_free(Sym *sym);
|
ST_INLN void sym_free(Sym *sym);
|
||||||
ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c);
|
ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c);
|
||||||
@ -1285,7 +1285,7 @@ ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info,
|
|||||||
ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int sh_num, const char *name);
|
ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int sh_num, const char *name);
|
||||||
ST_FUNC int find_elf_sym(Section *s, const char *name);
|
ST_FUNC int find_elf_sym(Section *s, const char *name);
|
||||||
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
|
ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
|
||||||
ST_FUNC void put_elf_reloca(Section *symtab, Section *s, unsigned long offset, int type, int symbol, unsigned long addend);
|
ST_FUNC void put_elf_reloca(Section *symtab, Section *s, unsigned long offset, int type, int symbol, addr_t addend);
|
||||||
|
|
||||||
ST_FUNC void put_stabs(const char *str, int type, int other, int desc, unsigned long value);
|
ST_FUNC void put_stabs(const char *str, int type, int other, int desc, unsigned long value);
|
||||||
ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc, unsigned long value, Section *sec, int sym_index);
|
ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc, unsigned long value, Section *sec, int sym_index);
|
||||||
|
|||||||
2
tccelf.c
2
tccelf.c
@ -270,7 +270,7 @@ ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size,
|
|||||||
|
|
||||||
/* put relocation */
|
/* put relocation */
|
||||||
ST_FUNC void put_elf_reloca(Section *symtab, Section *s, unsigned long offset,
|
ST_FUNC void put_elf_reloca(Section *symtab, Section *s, unsigned long offset,
|
||||||
int type, int symbol, unsigned long addend)
|
int type, int symbol, addr_t addend)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
Section *sr;
|
Section *sr;
|
||||||
|
|||||||
Reference in New Issue
Block a user