# Assemble asm files using CC · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/a038ef3570caed01815173d95089e016fab3a050)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: a038ef3570caed01815173d95089e016fab3a050

Requested commit: a038ef3570caed01815173d95089e016fab3a050

Commit: a038ef3570caed01815173d95089e016fab3a050

Tree: 62e157b941ddff639765b58212c8668fa177753c

Author: LemonBoy

Committer: LemonBoy

## Message

````
Assemble asm files using CC

Stuffing all the files together and compiling the resulting blob with
the main program is a terrible idea.

Some files, namely the .S ones, must be run trough the C preprocessor
before assembling them (#2437).

Beside that the aggregate may be mis-compiled due to the presence of
some flags that affect the following code.

For example let's consider two files, a.s and b.s

a.s
```
fn1:
    ret
.data
data1:
    .word 0
```

b.s
```
fn2:
    ret
```

Now, fn1 and fn2 will be both placed in the .text section as intended if
the two files are compiled separately. But if we merge them the `.data`
flag ends up placing fn2 in the wrong section!

This fixes a nasty crash where musl's memset ended up in the
non-executable data segment, leading to too many hours of
head-scratching.

````

## Parents

- [6cf7fb1177848c2f2a20c1f4093b1e003c477911](https://git.cafe/gitcafe/zig/commit/6cf7fb1177848c2f2a20c1f4093b1e003c477911?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/a038ef3570caed01815173d95089e016fab3a050?format=markdown)
