mirror of
https://github.com/TinyCC/tinycc.git
synced 2026-02-04 04:41:37 +00:00
Fix macos
I fixed macos problem with test case 60. Also tccrun mmap and debug code did not work.
This commit is contained in:
3
tccasm.c
3
tccasm.c
@@ -818,8 +818,11 @@ static void asm_parse_directive(TCCState *s1, int global)
|
||||
|
||||
tok1 = tok;
|
||||
next();
|
||||
if (tok < TOK_IDENT || tok >= SYM_FIRST_ANOM)
|
||||
goto nolab;
|
||||
sym = asm_label_find(tok);
|
||||
if (!sym) {
|
||||
nolab:
|
||||
tcc_error("label not found: %s", get_tok_str(tok1, NULL));
|
||||
}
|
||||
/* XXX .size name,label2-label1 */
|
||||
|
||||
4
tccelf.c
4
tccelf.c
@@ -2615,6 +2615,10 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr)
|
||||
|
||||
#if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
|
||||
ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
||||
#elif TARGETOS_OpenBSD
|
||||
ehdr.e_ident[EI_OSABI] = ELFOSABI_OPENBSD;
|
||||
#elif TARGETOS_NetBSD
|
||||
ehdr.e_ident[EI_OSABI] = ELFOSABI_NETBSD;
|
||||
#elif defined TCC_TARGET_ARM && defined TCC_ARM_EABI
|
||||
ehdr.e_flags = EF_ARM_EABI_VER5;
|
||||
ehdr.e_flags |= s1->float_abi == ARM_HARD_FLOAT
|
||||
|
||||
13
tccrun.c
13
tccrun.c
@@ -121,6 +121,9 @@ static int rt_mem(TCCState *s1, int size)
|
||||
ftruncate(fd, size);
|
||||
|
||||
ptr = mmap(NULL, size * 2, PROT_READ|PROT_EXEC|(s1->do_debug ? PROT_WRITE : 0), MAP_SHARED, fd, 0);
|
||||
if (ptr == MAP_FAILED)
|
||||
/* Some targets do not support PROT_EXEC + PROT_WRITE */
|
||||
ptr = mmap(NULL, size * 2, PROT_READ|PROT_EXEC, MAP_SHARED, fd, 0);
|
||||
/* mmap RW memory at fixed distance */
|
||||
prw = mmap((char*)ptr + size, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0);
|
||||
close(fd);
|
||||
@@ -356,13 +359,23 @@ redo:
|
||||
if (copy == 3)
|
||||
return 0;
|
||||
|
||||
#if defined TCC_TARGET_MACHO
|
||||
for (k = 0; k < 3; ++k) { /* 0:rx, 1:ro, 3:rw sections */
|
||||
#else
|
||||
for (k = 0; k < 4; ++k) { /* 0:rx, 1:ro, 2:ro debug , 3:rw sections */
|
||||
#endif
|
||||
n = 0; addr = 0;
|
||||
for(i = 1; i < s1->nb_sections; i++) {
|
||||
#if defined TCC_TARGET_MACHO
|
||||
static const char shf[] = {
|
||||
SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, SHF_ALLOC|SHF_WRITE
|
||||
};
|
||||
#else
|
||||
static const char shf[] = {
|
||||
SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, 0, SHF_ALLOC|SHF_WRITE
|
||||
};
|
||||
if (k == 2 && s1->do_debug == 0) continue;
|
||||
#endif
|
||||
s = s1->sections[i];
|
||||
if (shf[k] != (s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR)))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user