diff --git a/tcc.h b/tcc.h
index ac50a6da..2c2e086b 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1795,6 +1795,7 @@ ST_FUNC void tcc_debug_putfile(TCCState *s1, const char *filename);
 ST_FUNC void tcc_debug_line(TCCState *s1);
 ST_FUNC void tcc_add_debug_info(TCCState *s1, int param, Sym *s, Sym *e);
 ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym);
+ST_FUNC void tcc_debug_prolog_epilog(TCCState *s1, int value);
 ST_FUNC void tcc_debug_funcend(TCCState *s1, int size);
 ST_FUNC void tcc_debug_extern_sym(TCCState *s1, Sym *sym, int sh_num, int sym_bind, int sym_type);
 ST_FUNC void tcc_debug_typedef(TCCState *s1, Sym *sym);
diff --git a/tccdbg.c b/tccdbg.c
index 132f83e9..85d70865 100644
--- a/tccdbg.c
+++ b/tccdbg.c
@@ -971,6 +971,7 @@ ST_FUNC void tcc_debug_end(TCCState *s1)
 	    tcc_free(dwarf_line.filename_table[i].name);
 	tcc_free(dwarf_line.filename_table);
 
+	dwarf_line_op(s1, DW_LNS_negate_stmt);
 	dwarf_line_op(s1, 0); // extended
 	dwarf_uleb128_op(s1, 1); // extended size
 	dwarf_line_op(s1, DW_LNE_end_sequence);
@@ -1827,7 +1828,9 @@ ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym)
 
     if (s1->dwarf) {
         tcc_debug_line(s1);
+	dwarf_line_op(s1, DW_LNS_negate_stmt);
 	dwarf_line_op(s1, DW_LNS_copy);
+	dwarf_line_op(s1, DW_LNS_negate_stmt);
         dwarf_info.func = sym;
         dwarf_info.line = file->line_num;
 	if (s1->do_backtrace) {
@@ -1852,6 +1855,16 @@ ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym)
     }
 }
 
+ST_FUNC void tcc_debug_prolog_epilog(TCCState *s1, int value)
+{
+    if (!s1->do_debug)
+        return;
+    if (s1->dwarf) {
+	dwarf_line_op(s1, value == 0 ? DW_LNS_set_prologue_end
+				     : DW_LNS_set_epilogue_begin);
+    }
+}
+
 /* put function size */
 ST_FUNC void tcc_debug_funcend(TCCState *s1, int size)
 {
diff --git a/tccgen.c b/tccgen.c
index 4dd33323..bdaaf129 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -8165,6 +8165,7 @@ static void gen_function(Sym *sym)
     sym_push2(&local_stack, SYM_FIELD, 0, 0);
     local_scope = 1; /* for function parameters */
     gfunc_prolog(sym);
+    tcc_debug_prolog_epilog(tcc_state, 0);
     local_scope = 0;
     rsym = 0;
     clear_temp_local_var_list();
@@ -8174,6 +8175,7 @@ static void gen_function(Sym *sym)
     nocode_wanted = 0;
     /* reset local stack */
     pop_local_syms(NULL, 0);
+    tcc_debug_prolog_epilog(tcc_state, 1);
     gfunc_epilog();
     cur_text_section->data_offset = ind;
     local_scope = 0;
diff --git a/tccrun.c b/tccrun.c
index 8ed0a3d8..51b9a10d 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -246,6 +246,11 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
         rc->elf_str = (char *)symtab_section->link->data;
 #if PTR_SIZE == 8
         rc->prog_base = text_section->sh_addr & 0xffffffff00000000ULL;
+#if defined TCC_TARGET_MACHO
+	if (s1->dwarf)
+	    rc->prog_base = (addr_t) -1;
+#else
+#endif
 #endif
         rc->top_func = tcc_get_symbol(s1, "main");
         rc->num_callers = s1->rt_num_callers;
@@ -752,6 +757,9 @@ static addr_t rt_printline_dwarf (rt_context *rc, addr_t wanted_pc,
     } filename_table[FILE_TABLE_SIZE];
     addr_t last_pc;
     addr_t pc;
+#if defined TCC_TARGET_MACHO
+    addr_t first_pc = 0;
+#endif
     addr_t func_addr;
     int line;
     char *filename;
@@ -910,6 +918,11 @@ check_pc:
 		        pc = dwarf_read_4(cp, end);
 #else
 		        pc = dwarf_read_8(cp, end);
+#endif
+#if defined TCC_TARGET_MACHO
+			if (first_pc == 0 && rc->prog_base != (addr_t) -1)
+			    first_pc += rc->prog_base - ((uint64_t)1 << 32);
+			pc += first_pc;
 #endif
 		        opindex = 0;
 		        break;
diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile
index 4572c88d..2fdac705 100644
--- a/tests/tests2/Makefile
+++ b/tests/tests2/Makefile
@@ -58,9 +58,6 @@ ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))
  SKIP += 114_bound_signal.test # libc problem signal/fork
  SKIP += 116_bound_setjmp2.test # No TLS_FUNC/TLS_VAR in bcheck.c
 endif
-ifneq (,$(filter Darwin,$(TARGETOS)))
- SKIP += 126_bound_global.test # bt-exe.c problem on apple
-endif
 
 # Some tests might need arguments
 ARGS =