From 78da4586a002275e7f4c29d0f545430f1fc055e7 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Thu, 1 Oct 2020 17:52:16 +0200 Subject: [PATCH] Fix tests2/120_alias.c on macos While MacOS doesn't natively support the alias attribute, let's support it with TCC anyway. This means we need to make a decision if the string in the alias attribute is decorated or not due to the implicit underscore on MacOS. To make life easier we decide that it's the C name, i.e. without underscore, and so TCC needs to emit alias names with underscore handling. Irrespective of that the test case needs to deal with the underscore itself for __asm__ renaming which is always requiring the assembler name. --- tccgen.c | 2 +- tests/tests2/120_alias.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tccgen.c b/tccgen.c index 136e4b80..84b9420c 100644 --- a/tccgen.c +++ b/tccgen.c @@ -8472,7 +8472,7 @@ found: if (!esym) tcc_error("unsupported forward __alias__ attribute"); put_extern_sym2(sym, esym->st_shndx, - esym->st_value, esym->st_size, 0); + esym->st_value, esym->st_size, 1); } } else { if (type.t & VT_STATIC) diff --git a/tests/tests2/120_alias.c b/tests/tests2/120_alias.c index c9eb2985..5bead0f5 100644 --- a/tests/tests2/120_alias.c +++ b/tests/tests2/120_alias.c @@ -6,7 +6,11 @@ void target(void) { } void alias_for_target(void) __attribute__((alias("target"))); +#ifdef __leading_underscore +void asm_for_target(void) __asm__("_target"); +#else void asm_for_target(void) __asm__("target"); +#endif /* This is not supposed to compile, alias targets must be defined in the same unit. In TCC they even must be defined before the reference