asm embedded in C

1

Before, it was enough to do

int main(int argc,char **argv){
  char f[]="cadena"
  asm("mov %0,%%rdi\n\t"
  "call puts\n\t"
  ::""r"(f):"rdi")
}

and it worked, but not now. I tried to load the symbol __GLOBAL_OFFEST_TABLE_ (even from %rip ) add and subtract offsets from the libraries and call puts@PLT . But it only works if I do

int main(int argc,char **argv){
char f[]="cadena"
asm("mov %0,%%rdi\n\t"
    "callq puts@PLT\n\t"
    ::"r"(f):"rdi")

  puts(cadena);  //es decir cuando fuerzo la carga de la biblioteca
   //en C
}

Any solutions?

    
asked by FJsanto 17.01.2018 в 15:46
source

1 answer

0

First of all you have to put the ; at the end of the function asm() and then you must compile it from the terminal with gcc <filename.c> -masm=intel -o name

    
answered by 11.08.2018 в 01:40