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
818818
819819 tok1 = tok;
820820 next();
821+ if (tok < TOK_IDENT || tok >= SYM_FIRST_ANOM)
822+ goto nolab;
821823 sym = asm_label_find(tok);
822824 if (!sym) {
825+ nolab:
823826 tcc_error("label not found: %s", get_tok_str(tok1, NULL));
824827 }
825828 /* 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
26152615
26162616 #if TARGETOS_FreeBSD || TARGETOS_FreeBSD_kernel
26172617 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;
26182622 #elif defined TCC_TARGET_ARM && defined TCC_ARM_EABI
26192623 ehdr.e_flags = EF_ARM_EABI_VER5;
26202624 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
121121 ftruncate(fd, size);
122122
123123 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);
124127 /* mmap RW memory at fixed distance */
125128 prw = mmap((char*)ptr + size, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0);
126129 close(fd);
@@ -356,13 +359,23 @@ redo: · 229 unmodified lines
356359 if (copy == 3)
357360 return 0;
358361
362+#if defined TCC_TARGET_MACHO
363+ for (k = 0; k < 3; ++k) { /* 0:rx, 1:ro, 3:rw sections */
364+#else
359365 for (k = 0; k < 4; ++k) { /* 0:rx, 1:ro, 2:ro debug , 3:rw sections */
366+#endif
360367 n = 0; addr = 0;
361368 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
362374 static const char shf[] = {
363375 SHF_ALLOC|SHF_EXECINSTR, SHF_ALLOC, 0, SHF_ALLOC|SHF_WRITE
364376 };
365377 if (k == 2 && s1->do_debug == 0) continue;
378+#endif
366379 s = s1->sections[i];
367380 if (shf[k] != (s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR)))
368381 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