Hello,

The patch works perfectly !

Thanks

You can commit !

2016-11-09 16:18 GMT+01:00 Michael Matz <[email protected]>:

> Hello,
>
> On Mon, 7 Nov 2016, Thomas Stalder wrote:
>
> > I have tested with latests TinyCC git commit and sometimes i have the
> error
> > (with DEBUG_RELOC) :
> >
> > reloc 1: x=0xfffffe val=0x1eddc  newx=0xfdaf7d70 name=printf
> > tcc: error: can't relocate value at 2527064,1
>
> Out of range jump because no PLT is used for defined symbols, which can be
> a problem when compiling to memory and running from there when the
> compiled code calls functions defined in the executable itself but the
> code buffer is allocated too far away from those definitions.  I fixed a
> similar problem for aarch64 in 682ecc17, probably arm needs something
> similar.  Untested patch below, which possibly works around this, please
> try.
>
>
> Ciao,
> Michael.
>
> diff --git a/tccelf.c b/tccelf.c
> index 1e05bfb..a027700 100644
> --- a/tccelf.c
> +++ b/tccelf.c
> @@ -828,7 +828,8 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
>              {
>                  int x, is_thumb, is_call, h, blx_avail, is_bl, th_ko;
>                  x = (*(int *) ptr) & 0xffffff;
> -               if (sym->st_shndx == SHN_UNDEF)
> +               if (sym->st_shndx == SHN_UNDEF
> +                   || s1->output_type == TCC_OUTPUT_MEMORY)
>                     val = s1->plt->sh_addr;
>  #ifdef DEBUG_RELOC
>                 printf ("reloc %d: x=0x%x val=0x%x ", type, x, val);
> @@ -1578,7 +1579,8 @@ ST_FUNC void build_got_entries(TCCState *s1)
>                  sym_index = ELFW(R_SYM)(rel->r_info);
>                  sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
>                 if (type != R_ARM_GOTOFF && type != R_ARM_GOTPC
> -                   && sym->st_shndx == SHN_UNDEF) {
> +                   && (sym->st_shndx == SHN_UNDEF
> +                       || s1->output_type == TCC_OUTPUT_MEMORY)) {
>                      unsigned long ofs;
>                      /* look at the symbol got offset. If none, then add
> one */
>                      if (type == R_ARM_GOT32)
>
> _______________________________________________
> Tinycc-devel mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to