mirror of
https://github.com/rui314/chibicc
synced 2024-11-23 14:49:40 +03:00
Add -Xlinker option
This commit is contained in:
parent
d1bc9a4eb0
commit
469f159bb1
9
main.c
9
main.c
@ -40,7 +40,9 @@ static void usage(int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool take_arg(char *arg) {
|
static bool take_arg(char *arg) {
|
||||||
char *x[] = {"-o", "-I", "-idirafter", "-include", "-x", "-MF", "-MT"};
|
char *x[] = {
|
||||||
|
"-o", "-I", "-idirafter", "-include", "-x", "-MF", "-MT", "-Xlinker",
|
||||||
|
};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(x) / sizeof(*x); i++)
|
for (int i = 0; i < sizeof(x) / sizeof(*x); i++)
|
||||||
if (!strcmp(arg, x[i]))
|
if (!strcmp(arg, x[i]))
|
||||||
@ -213,6 +215,11 @@ static void parse_args(int argc, char **argv) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(argv[i], "-Xlinker")) {
|
||||||
|
strarray_push(&ld_extra_args, argv[++i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[i], "-s")) {
|
if (!strcmp(argv[i], "-s")) {
|
||||||
strarray_push(&ld_extra_args, "-s");
|
strarray_push(&ld_extra_args, "-s");
|
||||||
continue;
|
continue;
|
||||||
|
@ -302,4 +302,11 @@ 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
|
cc -Wl,-z,muldefs,--gc-sections -o $tmp/foo $tmp/foo.o $tmp/bar.o $tmp/baz.o
|
||||||
check -Wl,
|
check -Wl,
|
||||||
|
|
||||||
|
# -Xlinker
|
||||||
|
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 -Xlinker -z -Xlinker muldefs -Xlinker --gc-sections -o $tmp/foo $tmp/foo.o $tmp/bar.o $tmp/baz.o
|
||||||
|
check -Xlinker
|
||||||
|
|
||||||
echo OK
|
echo OK
|
||||||
|
Loading…
Reference in New Issue
Block a user