tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH] TCC arm64 back end


From: Edmund Grimley Evans
Subject: Re: [Tinycc-devel] [PATCH] TCC arm64 back end
Date: Wed, 11 Mar 2015 15:46:53 +0000

I wrote:

> There seems to be a general problem with TCC not using a PLT when it
> should. Without the PLT it works all of the time on i386 and some of
> the time on arm64, depending on the environment. So you really need to
> print the addresses that are being used to check that they are in the
> PLT and that TCC isn't trying to branch directly to a different
> library/executable which might not necessarily be within range of a
> branch instruction.

I'll try to be more specific. For example, take this program:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
  printf("PLT:\n");
  printf("%p atoi\n", atoi);
  printf("%p printf\n", printf);
  printf("%p sin\n", sin);
  printf("GOT:\n");
  printf("%p signgam\n", &signgam);
  printf("%p stdin\n", &stdin);
  printf("%p stdout\n", &stdout);
  printf("%p stderr\n", &stderr);
  return 0;
}

If you run it you should get something like:

PLT:
0x4006a0 atoi
0x400660 printf
0x400690 sin
GOT:
0x601050 signgam
0x601048 stdin
0x601040 stdout
0x601058 stderr

Note how all the PLT addresses, and all the GOT addresses are close to
each other.

The same should be true when the program is linked by TCC, or executed
using tcc -run, or run with libtcc, I think. Currently it isn't, if I
recall correctly.

Edmund



reply via email to

[Prev in Thread] Current Thread [Next in Thread]