[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] FIXED: tcc on fc4 ?
From: |
Kim Lux |
Subject: |
[Tinycc-devel] FIXED: tcc on fc4 ? |
Date: |
Thu, 15 Dec 2005 11:31:15 -0700 |
I fixed the problem: I had to add am ld_next call to get the next
filename for the loop.
Here is what I get on fc4 now:
tcc ./examples/ex1.c
cmd is GROUP
filename is /lib/libc.so.6
Adding /lib/libc.so.6
filename is /usr/lib/libc_nonshared.a
Adding /usr/lib/libc_nonshared.a
filename is AS_NEEDED
AS_NEEDED found
AS_NEEDED filename is /lib/ld-linux.so.2
Adding /lib/ld-linux.so.2
$ ./a.out
Hello World
I am going to leave the printfs in so that I can watch for issues for a
bit.
Here is the fixed code:
/* interpret a subset of GNU ldscripts to handle the dummy libc.so
files */
static int tcc_load_ldscript(TCCState *s1)
{
char cmd[64];
char filename[1024];
int t;
ch = file->buf_ptr[0];
ch = handle_eob();
for(;;) {
t = ld_next(s1, cmd, sizeof(cmd));
if (t == LD_TOK_EOF)
return 0;
else if (t != LD_TOK_NAME)
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; //found the end of the GROUP line
} else if (t != LD_TOK_NAME) {
error_noabort("filename expected");
return -1;
}
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 */
t = ld_next(s1, cmd, sizeof(cmd));
if (t != '(')
expect("(");
for(;;) {
t = ld_next(s1, filename, sizeof(filename));
if (t == LD_TOK_EOF) {
error_noabort("unexpected end of file");
return -1;
} else if (t == ')') {
break;
}
}
}
else {
return -1;
}
}
return 0;
}
--
Kim Lux, Diesel Research Inc.