It looks it is broken since Thomas commit:

 


commit

776aa0c093cc6083cbb61d0db8e303209b21bbad


author

 
<https://repo.or.cz/tinycc.git/search/776aa0c093cc6083cbb61d0db8e303209b21bb
ad?s=Thomas+Preud%27homme;st=author> Thomas Preud'homme
<https://repo.or.cz/tinycc.git/search/776aa0c093cc6083cbb61d0db8e303209b21bb
[email protected];st=author> <[email protected]>

        
        
Sat, 24 Feb 2018 16:50:14 +0100 (24 15:50 +0000)


committer

 
<https://repo.or.cz/tinycc.git/search/776aa0c093cc6083cbb61d0db8e303209b21bb
ad?s=Thomas+Preud%27homme;st=committer> Thomas Preud'homme
<https://repo.or.cz/tinycc.git/search/776aa0c093cc6083cbb61d0db8e303209b21bb
[email protected];st=committer> <[email protected]>

        
        
Sat, 24 Feb 2018 20:35:15 +0100 (24 19:35 +0000)


tree

0092974992ee82aa3971f6003dbf18d754ad1fd1
<https://repo.or.cz/tinycc.git/tree/776aa0c093cc6083cbb61d0db8e303209b21bbad
> 

tree
<https://repo.or.cz/tinycc.git/tree/776aa0c093cc6083cbb61d0db8e303209b21bbad
>  | snapshot (tar.gz
<https://repo.or.cz/tinycc.git/snapshot/776aa0c093cc6083cbb61d0db8e303209b21
bbad.tar.gz>  zip
<https://repo.or.cz/tinycc.git/snapshot/776aa0c093cc6083cbb61d0db8e303209b21
bbad.zip> )


parent

3e6515b64fe615b90dc758d95862a1626494862f
<https://repo.or.cz/tinycc.git/commit/3e6515b64fe615b90dc758d95862a162649486
2f> 

commit
<https://repo.or.cz/tinycc.git/commit/3e6515b64fe615b90dc758d95862a162649486
2f>  | diff
<https://repo.or.cz/tinycc.git/commitdiff/776aa0c093cc6083cbb61d0db8e303209b
21bbad?hp=3e6515b64fe615b90dc758d95862a1626494862f> 

Prevent dead code on !x86 in prepare_dynamic_rel

In prepare_dynamic_rel() on non x86 targets the count++ statements
appear before any case label and are therefore dead code. This triggers
build failure when building with -Werror. This patch adds an extra guard
around all the x86 case labels and their associated action, leaving just
the default case label for non x86 targets which builds fine.

 

I propose this patch which, at least on Windows x64 fixes compilation error.
Thomas, can you please review this patch and apply it in mod if you agree?

 

diff --git a/tccelf.c b/tccelf.c

index ead8eed..d381c4f 100644

--- a/tccelf.c

+++ b/tccelf.c

@@ -866,12 +866,14 @@ static void relocate_rel(TCCState *s1, Section *sr)

static int prepare_dynamic_rel(TCCState *s1, Section *sr)

{

     ElfW_Rel *rel;

-    int sym_index, type, count;

+    int type, count;

 

     count = 0;

     for_each_elem(sr, 0, rel, ElfW_Rel) {

-        sym_index = ELFW(R_SYM)(rel->r_info);

         type = ELFW(R_TYPE)(rel->r_info);

+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)

+        int sym_index = ELFW(R_SYM)(rel->r_info);

+#endif

         switch(type) {

#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)

#if defined(TCC_TARGET_I386)

 

From: Tinycc-devel [mailto:[email protected]]
On Behalf Of Christian Jullien
Sent: vendredi 7 décembre 2018 07:04
To: [email protected]
Subject: [Tinycc-devel] tcc no longer compiles on Windows

 

Tccelf.c has an undefined reference to sym_index with R_X86_64_PC32 case
line 897.

 

The declaration of sym_index at line 877 is not covered by this case.

 

static int prepare_dynamic_rel(TCCState *s1, Section *sr)

{

    ElfW_Rel *rel;

    int type, count;

 

    count = 0;

    for_each_elem(sr, 0, rel, ElfW_Rel) {

        type = ELFW(R_TYPE)(rel->r_info);

        switch(type) {

#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)

#if defined(TCC_TARGET_I386)

        int sym_index = ELFW(R_SYM)(rel->r_info);  <<<< definition limited
to I386

        case R_386_32:

            if (!get_sym_attr(s1, sym_index, 0)->dyn_index

                && ((ElfW(Sym)*)symtab_section->data + sym_index)->st_shndx
== SHN_UNDEF) {

                /* don't fixup unresolved (weak) symbols */

                rel->r_info = ELFW(R_INFO)(sym_index, R_386_RELATIVE);

                break;

            }

#elif defined(TCC_TARGET_X86_64)

        case R_X86_64_32:

        case R_X86_64_32S:

        case R_X86_64_64:

#endif

            count++;

            break;

#if defined(TCC_TARGET_I386)

        case R_386_PC32:

#elif defined(TCC_TARGET_X86_64)

        case R_X86_64_PC32:

#endif

            if (get_sym_attr(s1, sym_index, 0)->dyn_index)

                count++;

            break;

#endif

        default:

            break;

        }

    }

    if (count) {

        /* allocate the section */

        sr->sh_flags |= SHF_ALLOC;

        sr->sh_size = count * sizeof(ElfW_Rel);

    }

    return count;

}

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to