mirror of https://github.com/rui314/chibicc.git
Add -Wl, option
This commit is contained in:
parent
c8df7874c6
commit
d1bc9a4eb0
12
main.c
12
main.c
|
@ -208,7 +208,7 @@ static void parse_args(int argc, char **argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(argv[i], "-l", 2)) {
|
||||
if (!strncmp(argv[i], "-l", 2) || !strncmp(argv[i], "-Wl,", 4)) {
|
||||
strarray_push(&input_paths, argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
@ -714,6 +714,16 @@ int main(int argc, char **argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(input, "-Wl,", 4)) {
|
||||
char *s = strdup(input + 4);
|
||||
char *arg = strtok(s, ",");
|
||||
while (arg) {
|
||||
strarray_push(&ld_args, arg);
|
||||
arg = strtok(NULL, ",");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
char *output;
|
||||
if (opt_o)
|
||||
output = opt_o;
|
||||
|
|
|
@ -295,4 +295,11 @@ echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c
|
|||
$chibicc -o $tmp/foo $tmp/bar.c -L$tmp -lfoobar
|
||||
check -L
|
||||
|
||||
# -Wl,
|
||||
echo 'int foo() {}' | $chibicc -c -o $tmp/foo.o -xc -
|
||||
echo 'int foo() {}' | $chibicc -c -o $tmp/bar.o -xc -
|
||||
echo 'int main() {}' | $chibicc -c -o $tmp/baz.o -xc -
|
||||
cc -Wl,-z,muldefs,--gc-sections -o $tmp/foo $tmp/foo.o $tmp/bar.o $tmp/baz.o
|
||||
check -Wl,
|
||||
|
||||
echo OK
|
||||
|
|
Loading…
Reference in New Issue