History

ignore AS_NEEDED ld command

bellard committed 21 years ago

Commit bb24eb91 parent 44738b51 file · +40 −21Browse files

Unified · Split

tccelf.c+40−21
@@ -2277,13 +2277,49 @@ static int ld_next(TCCState *s1, char *name, int name_size) · 2276 unmodified lines
22772277 return c;
22782278 }
22792279
2280+static int ld_add_file_list(TCCState *s1, int as_needed)
2281+{
2282+ char filename[1024];
2283+ int t, ret;
2284+
2285+ t = ld_next(s1, filename, sizeof(filename));
2286+ if (t != '(')
2287+ expect("(");
2288+ t = ld_next(s1, filename, sizeof(filename));
2289+ for(;;) {
2290+ if (t == LD_TOK_EOF) {
2291+ error_noabort("unexpected end of file");
2292+ return -1;
2293+ } else if (t == ')') {
2294+ break;
2295+ } else if (t != LD_TOK_NAME) {
2296+ error_noabort("filename expected");
2297+ return -1;
2298+ }
2299+ if (!strcmp(filename, "AS_NEEDED")) {
2300+ ret = ld_add_file_list(s1, 1);
2301+ if (ret)
2302+ return ret;
2303+ } else {
2304+ /* TODO: Implement AS_NEEDED support. Ignore it for now */
2305+ if (!as_needed)
2306+ tcc_add_file(s1, filename);
2307+ }
2308+ t = ld_next(s1, filename, sizeof(filename));
2309+ if (t == ',') {
2310+ t = ld_next(s1, filename, sizeof(filename));
2311+ }
2312+ }
2313+ return 0;
2314+}
2315+
22802316 /* interpret a subset of GNU ldscripts to handle the dummy libc.so
22812317 files */
22822318 static int tcc_load_ldscript(TCCState *s1)
22832319 {
22842320 char cmd[64];
22852321 char filename[1024];
2286− int t;
2322+ int t, ret;
22872323
22882324 ch = file->buf_ptr[0];
22892325 ch = handle_eob();
@@ -2295,26 +2331,9 @@ static int tcc_load_ldscript(TCCState *s1) · 5 unmodified lines
22952331 return -1;
22962332 if (!strcmp(cmd, "INPUT") ||
22972333 !strcmp(cmd, "GROUP")) {
2298− t = ld_next(s1, cmd, sizeof(cmd));
2299− if (t != '(')
2300− expect("(");
2301− t = ld_next(s1, filename, sizeof(filename));
2302− for(;;) {
2303− if (t == LD_TOK_EOF) {
2304− error_noabort("unexpected end of file");
2305− return -1;
2306− } else if (t == ')') {
2307− break;
2308− } else if (t != LD_TOK_NAME) {
2309− error_noabort("filename expected");
2310− return -1;
2311− }
2312− tcc_add_file(s1, filename);
2313− t = ld_next(s1, filename, sizeof(filename));
2314− if (t == ',') {
2315− t = ld_next(s1, filename, sizeof(filename));
2316− }
2317− }
2334+ ret = ld_add_file_list(s1, 0);
2335+ if (ret)
2336+ return ret;
23182337 } else if (!strcmp(cmd, "OUTPUT_FORMAT") ||
23192338 !strcmp(cmd, "TARGET")) {
23202339 /* ignore some commands */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t