Basically I am trying to re-use some asm code disassembled from a binary on x86 32bit Linux.I am facing some trouble when references of GOT/GOT.PLT involved like these.  ....  804c460:       53                      push   %ebx  804c461:       e8 ec ff ff ff          call   804c452 <__i686.get_pc_thunk.bx>  804c466:       81 c3 8e 2b 00 00       add    $0x2b8e,%ebx   // %ebx has the beginning address of GOT table  804c46c:       83 ec 18                sub    $0x18,%esp  ....If I want to re-use these asm code, I have to lift concrete address into symbols, and it seems that in the above code, I have to find a way to let ebx store the begin address of GOT table.Well... then do I have to modify the linker...? Because the begin address of GOT table can't be decided until link time..So my questions are:Is modifying linker a right way to do this ..? Is there any other way?How to modify the linker in this issue..? I basically have no experiences before.. 
How to re-use some asm code when GOT/GOT.PLT references involved?
disassembly;assembly;reassembly;dynamic linking
If you're using GAS or a compatible assembler, you can use special modifiers to have it emit relocation info for GOT-based addressing.Here's the gcc -S output of a typical prolog of a function compiled with -fPIC:call    __i686.get_pc_thunk.bxaddl    $_GLOBAL_OFFSET_TABLE_, %ebxleal    .LC0@GOTOFF(%ebx), %eaxmovl    %eax, (%esp)call    puts@PLTAs you can see, you can replace the %ebx addendum with $_GLOBAL_OFFSET_TABLE_, and other GOT-relative offsets with symbol@GOTOFF. In some cases you may also need @GOTPLT or @GOTPCREL modifiers. See here for more info (mostly x64-specific, but still useful).If your file is relocatable or a shared object, disassembling it with -dr (so you see relocation info) can be useful to see places where you may need to add back the symbol modifiers.