http://www.mail-archive.com/tinycc-devel%40nongnu.org/msg00297.html --- tccelf.c 2005-06-18 00:09:15.000000000 +0200 +++ tccelf.c.oden 2006-06-04 12:51:07.000000000 +0200 @@ -2284,7 +2284,7 @@ char cmd[64]; char filename[1024]; int t; - + ch = file->buf_ptr[0]; ch = handle_eob(); for(;;) { @@ -2295,26 +2295,58 @@ return -1; if (!strcmp(cmd, "INPUT") || !strcmp(cmd, "GROUP")) { + printf("cmd is %s\n", cmd); //I added t = ld_next(s1, cmd, sizeof(cmd)); if (t != '(') expect("("); t = ld_next(s1, filename, sizeof(filename)); + printf("filename is %s\n",filename); for(;;) { if (t == LD_TOK_EOF) { error_noabort("unexpected end of file"); return -1; } else if (t == ')') { - break; + break; //found the end of the GROUP line } else if (t != LD_TOK_NAME) { error_noabort("filename expected"); return -1; - } - tcc_add_file(s1, filename); - t = ld_next(s1, filename, sizeof(filename)); + } + else{ // It must be a filename + printf("Adding %s\n", filename); + tcc_add_file(s1, filename); + t = ld_next(s1, filename, sizeof(filename)); + printf("filename is %s \n",filename); + } + // this line doesn't work... should be before else filename + // TODO: check/fix this if (t == ',') { t = ld_next(s1, filename, sizeof(filename)); } - } + + // Add a hack here to fix the AS_NEEDED issue + // ONLY works for a single file in the AS_NEEDED list. + // example: + //GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 )) + if (!strcmp(filename, "AS_NEEDED")) + { + printf("AS_NEEDED found\n"); + // get the "(" for the AS_NEEDED + t = ld_next(s1, cmd, sizeof(cmd)); + if (t != '(') + expect("("); + //get the real filename + t = ld_next(s1, filename, sizeof(filename)); + printf("AS_NEEDED filename is %s\n",filename); + printf("Adding %s\n", filename); + tcc_add_file(s1, filename); + // get the ")" for the AS_NEEDED + t = ld_next(s1, cmd, sizeof(cmd)); + if (t != ')') + expect(")"); + // get the next filename for the loop + t = ld_next(s1, filename, sizeof(filename)); + }// if AS_NEEDED + }//for... } else if (!strcmp(cmd, "OUTPUT_FORMAT") || !strcmp(cmd, "TARGET")) { /* ignore some commands */ @@ -2330,7 +2362,8 @@ break; } } - } else { + } + else { return -1; } }