summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorMura Li <mura_li@castech.com.tw>2017-11-28 17:54:06 +0800
committerOri Bernstein <ori@eigenstate.org>2017-11-30 01:19:02 -0800
commit28cea7b851f71fe07e4491dc8ec6eeee2e1c8011 (patch)
tree3b9778e49e3a311cb9e669a02711cd6d74379957 /6
parent83eef0360e0c66ff50d2874e1829470101e2afab (diff)
downloadmc-28cea7b851f71fe07e4491dc8ec6eeee2e1c8011.tar.gz
Generate per-function ELF sections to enable --gc-sections
Use diffirent directive syntax for ELF and Mach-O respectively
Diffstat (limited to '6')
-rw-r--r--6/gengas.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/6/gengas.c b/6/gengas.c
index d37f37e..6437c82 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -244,6 +244,17 @@ writeasm(FILE *fd, Isel *s, Func *fn)
{
size_t i, j;
+ switch (asmsyntax) {
+ case Gnugaself:
+ fprintf(fd, ".section .text.%s,\"ax\",@progbits\n", fn->name);
+ fprintf(fd, ".type %s, @function\n", fn->name);
+ break;
+ case Gnugasmacho:
+ fprintf(fd, ".section __TEXT,__text,regular\n");
+ break;
+ default:
+ die("unknown target"); break;
+ }
if (fn->isexport)
fprintf(fd, ".globl %s\n", fn->name);
fprintf(fd, "%s:\n", fn->name);