History

Fix macos

I fixed macos problem with test case 60. Also tccrun mmap and debug code did not work.

herman ten brugge committed 10 months ago

Commit 14019671 parent 1fe3e3b3 files · +20 −0Browse files

Unified · Split

3 files
  1. tccasm.c +3 −0
  2. tccelf.c +4 −0
  3. tccrun.c +13 −0
tccasm.c+3−0
@@ -818,8 +818,11 @@ static void asm_parse_directive(TCCState *s1, int global) · 817 unmodified lines
818 818
819 tok1 = tok;819 tok1 = tok;
820 next();820 next();
821 if (tok < TOK_IDENT || tok >= SYM_FIRST_ANOM)
822 goto nolab;
821 sym = asm_label_find(tok);823 sym = asm_label_find(tok);
822 if (!sym) {824 if (!sym) {
825 nolab:
823 tcc_error("label not found: %s", get_tok_str(tok1, NULL));826 tcc_error("label not found: %s", get_tok_str(tok1, NULL));
824 }827 }
825 /* XXX .size name,label2-label1 */828 /* XXX .size name,label2-label1 */
tccelf.c+4−0
@@ -2615,6 +2615,10 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) · 2614 unmodified lines
2615 2615
2616#if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel2616#if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
2617 ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;2617 ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
2618#elif TARGETOS_OpenBSD
2619 ehdr.e_ident[EI_OSABI] = ELFOSABI_OPENBSD;
2620#elif TARGETOS_NetBSD
2621 ehdr.e_ident[EI_OSABI] = ELFOSABI_NETBSD;
2618#elif defined TCC_TARGET_ARM && defined TCC_ARM_EABI2622#elif defined TCC_TARGET_ARM && defined TCC_ARM_EABI
2619 ehdr.e_flags = EF_ARM_EABI_VER5;2623 ehdr.e_flags = EF_ARM_EABI_VER5;
2620 ehdr.e_flags |= s1->float_abi == ARM_HARD_FLOAT2624 ehdr.e_flags |= s1->float_abi == ARM_HARD_FLOAT
tccrun.c+13−0
@@ -121,6 +121,9 @@ static int rt_mem(TCCState *s1, int size) · 120 unmodified lines
121 ftruncate(fd, size);121 ftruncate(fd, size);
122 122
123 ptr = mmap(NULL, size * 2, PROT_READ|PROT_EXEC|(s1->do_debug ? PROT_WRITE : 0), MAP_SHARED, fd, 0);123 ptr = mmap(NULL, size * 2, PROT_READ|PROT_EXEC|(s1->do_debug ? PROT_WRITE : 0), MAP_SHARED, fd, 0);
124 if (ptr == MAP_FAILED)
125 /* Some targets do not support PROT_EXEC + PROT_WRITE */
126 ptr = mmap(NULL, size * 2, PROT_READ|PROT_EXEC, MAP_SHARED, fd, 0);
124 /* mmap RW memory at fixed distance */127 /* mmap RW memory at fixed distance */
125 prw = mmap((char*)ptr + size, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0);128 prw = mmap((char*)ptr + size, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0);
126 close(fd);129 close(fd);
@@ -356,13 +359,23 @@ redo: · 229 unmodified lines
356 if (copy == 3)359 if (copy == 3)
357 return 0;360 return 0;
358 361
362#if defined TCC_TARGET_MACHO
363 for (k = 0; k < 3; ++k) { /* 0:rx, 1:ro, 3:rw sections */
364#else
359 for (k = 0; k < 4; ++k) { /* 0:rx, 1:ro, 2:ro debug , 3:rw sections */365 for (k = 0; k < 4; ++k) { /* 0:rx, 1:ro, 2:ro debug , 3:rw sections */
366#endif
360 n = 0; addr = 0;367 n = 0; addr = 0;
361 for(i = 1; i < s1->nb_sections; i++) {368 for(i = 1; i < s1->nb_sections; i++) {
369#if defined TCC_TARGET_MACHO
370 static const char shf[] = {
371 SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, SHF_ALLOC|SHF_WRITE
372 };
373#else
362 static const char shf[] = {374 static const char shf[] = {
363 SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, 0, SHF_ALLOC|SHF_WRITE375 SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, 0, SHF_ALLOC|SHF_WRITE
364 };376 };
365 if (k == 2 && s1->do_debug == 0) continue;377 if (k == 2 && s1->do_debug == 0) continue;
378#endif
366 s = s1->sections[i];379 s = s1->sections[i];
367 if (shf[k] != (s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR)))380 if (shf[k] != (s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR)))
368 continue;381 continue;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t