On Wed, Jun 15, 2005 at 12:57:49PM +0200, Nicholas Allen wrote:
>Hi,
>
>I don't know if I have done something wrong or if tcc needs updates to work 
>with recent Linux distributions. I am using Ubuntu with gcc 3.3.5 and when I 
>try to compile hello.c with the following command:
>
>tcc hello.c -o hello
>
>I get the following error:
>
>/usr/lib/crtn.o: Invalid relocation entry
>
>This always used to work but since I have upgraded to Ubuntu it no longer 
>does. I have the latest version of tcc from CVS and have recompiled on Ubuntu 
>but I still get this error. Anyone know what this could be caused by?


The attached patch makes it work for me. Can you confirm that?

Relocation section '.rel.debug_line' at offset 0x6ec contains 3 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
0000005a  00000801 R_386_32          00000000   .gnu.linkonce.t.__i686
0000006a  00000701 R_386_32          00000000   .fini
0000007c  00000601 R_386_32          00000000   .init

--- tinycc.oorig/tccelf.c       2005-09-05 23:04:12.000000000 +0200
+++ tinycc.tmp/tccelf.c 2005-09-28 21:50:52.000000000 +0200
@@ -204,8 +204,8 @@ static int add_elf_sym(Section *s, unsig
                 /* weak is ignored if already global */
             } else {
 #if 0
-                printf("new_bind=%d new_shndx=%d last_bind=%d old_shndx=%d\n",
-                       sym_bind, sh_num, esym_bind, esym->st_shndx);
+             printf("%12d new_bind=%d new_shndx=%d last_bind=%d 
old_shndx=%d\n",
+                       sym_index, sym_bind, sh_num, esym_bind, esym->st_shndx);
 #endif
                 /* NOTE: we accept that two DLL define the same symbol */
                 if (s != tcc_state->dynsymtab_section)
@@ -1874,7 +1874,6 @@ static int tcc_load_object_file(TCCState
 
     /* second short pass to update sh_link and sh_info fields of new
        sections */
-    sm = sm_table;
     for(i = 1; i < ehdr.e_shnum; i++) {
         s = sm_table[i].s;
         if (!s || !sm_table[i].new_section)
@@ -1888,6 +1887,7 @@ static int tcc_load_object_file(TCCState
             s1->sections[s->sh_info]->reloc = s;
         }
     }
+    sm = sm_table;
 
     /* resolve symbols */
     old_to_new_syms = tcc_mallocz(nb_syms * sizeof(int));
@@ -1949,9 +1949,12 @@ static int tcc_load_object_file(TCCState
                 if (sym_index >= nb_syms)
                     goto invalid_reloc;
                 sym_index = old_to_new_syms[sym_index];
-                if (!sym_index) {
+                /* ignore link_once in rel section.  */
+                if (!sym_index && !sm->link_once) {
                 invalid_reloc:
                     error_noabort("Invalid relocation entry");
+                   error_noabort("  [%2d] '%s' @%.8x", i,
+                                   strsec + sh->sh_name, rel->r_offset);
                     goto fail;
                 }
                 rel->r_info = ELF32_R_INFO(sym_index, type);
@@ -2066,7 +2069,7 @@ static int tcc_load_archive(TCCState *s1
                 break;
         }
         ar_name[i + 1] = '\0';
-        //        printf("name='%s' size=%d %s\n", ar_name, size, ar_size);
+/*        printf("name='%s' size=%d %s\n", ar_name, size, ar_size);*/
         file_offset = lseek(fd, 0, SEEK_CUR);
         /* align to even */
         size = (size + 1) & ~1;
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to