Skip to content

Commit

Permalink
WIP add -soname support
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Feb 17, 2023
1 parent f21ddbd commit c457572
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void usage(int status) {
static bool take_arg(char *arg) {
char *x[] = {
"-o", "-I", "-idirafter", "-include", "-x", "-MF", "-MT", "-Xlinker",
"-soname"
};

for (int i = 0; i < sizeof(x) / sizeof(*x); i++)
Expand Down Expand Up @@ -146,6 +147,12 @@ static void parse_args(int argc, char **argv) {
continue;
}

if (!strcmp(argv[i], "-soname")) {
strarray_push(&ld_extra_args, argv[i]);
strarray_push(&ld_extra_args, argv[++i]);
continue;
}

if (!strcmp(argv[i], "-S")) {
opt_S = true;
continue;
Expand Down
5 changes: 5 additions & 0 deletions test/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,9 @@ 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

# -soname
echo 'int main() { return 0; }' | $chibicc -c -o $tmp/foo.o -xc -
cc -shared -soname libfoo.so.0 -o $tmp/libfoo.so $tmp/foo.o
check -soname

echo OK

0 comments on commit c457572

Please sign in to comment.