[Vm-dev] IMPORTANT: GCC 6 generates position independent executables by default on Linux
Holger Freyther
holger at freyther.de
Wed Feb 22 09:51:37 UTC 2017
> On 22 Feb 2017, at 14:58, Ronie Salgado <roniesalg at gmail.com> wrote:
Dear Ronie,
> GDB layout asm on the line 25313 shows the generated code.
>
> B+>│0x565aac77 <interpret+214836> flds -0x1d6c(%ebp) │
> │0x565aac7d <interpret+214842> sub $0x8,%esp │
> │0x565aac80 <interpret+214845> lea -0x8(%esp),%esp │
> │0x565aac84 <interpret+214849> fstpl (%esp) │
> │0x565aac87 <interpret+214852> mov -0x4008(%ebp),%ebx │
> │0x565aac8d <interpret+214858> call 0x56570840
>
>
> Of special importance, is the instruction: mov -0x4008(%ebp),%ebx . this is the PLT entry for sqrt, and this is where ebx with the currentBytecode is destroyed.
I tried to reproduce it but I think I don't generate enough register pressure?
#include <stdint.h>
#include <sys/types.h>
#include <math.h>
int interpret(int *ops, const size_t num_ops)
{
register int op __asm__("%ebx");
size_t off = 0;
while (off < num_ops) {
op = ops[off];
switch(op) {
case 1:
case 2:
sqrt(op + num_ops);
break;
default:
break;
}
off += 1;
}
}
can you think of a way to get closer to the interpreter? Is it using computed goto? If there is a reproducer I am happy to open a bug with the GCC project and try to bring it to a resolution.
holger
More information about the Vm-dev
mailing list