OK, so basically I want to re-use the content from dumped .rodata data and bss section from ELF on Linux 32bit.The dump command:objdump -s -j .text elf_binaryobjdump -s -j .rodata elf_binaryobjdump -s -j .data elf_binaryand for the .bss section, I am preparing to re-use a bunch of 00000000 which has the same size of the bss section.It works fine when I re-use it in nasm assembler in this way..section rodataS_label1: db 0x01         db 0x02         ....  .section data        db 0x01S_label2:  db 0x02         .....section bssS_label3: db 0x00         db 0x00         ....nasm -f elf test.sBut basically my question is that:how to re-use these dumped sections in gas asssembler?Basically gas has a different assemble style, and apparently the data sections representations are different...I tried for several times and I still can not find the solution..Did I clearly demonstrate my question..? Could anyone give me some help?=======update==========So basically I want to re-use the rodata data and bss sections dumped from another binary.For example, here is the content of rodata section03000000 01000200 0a0a556e 736f727465642061 72726179 2069733a 2020002025642000 0a0a536f 72746564 2061727261792069 733a2020 00and I can re-use it in this way:label1: db 0x03db 0x00db 0x00db 0x00label2: db 0x01db 0x00db 0x02db 0x00.....mov eax, label1      // of course I will guarantee that I use it correctly....Basically in nasm, I can easily re-use them in the above way, but my question is that , how can I re-use it in gas (or directly use gcc) in a similiar way?Is it possible?
How to directly re-use the dumped content of `.rodata`, `.data` and `.bss` section?
disassembly;assembly;nasm
As an assembly programmer I would say that gas is rarely used to assemble external code. The task of calling gas is usually left to the compiler, and most of the assembly that gas has to handle in real life is either inlined inside C or C++ code or comes from a compiler. But, I believe this document by Dean Elsner, Jay Fenlanson & friends is by far the best reference I managed to rely on for quite sometime. It has been updated many times and it covers the 2.19.51 version.The easy way would be to use GCC I would say :  //Just to avoid make a point :]  typedef unsigned char byte;  //  byte lbl1[] = { 0x03, 0x00, 0x00, 0x00, ... },        lbl2[] = { 0x01, 0x00, 0x02, 0x00, ... };  //I prefer Intel syntax rather than AT&T, it's somehow cleaner !  __asm__(intel_syntax noprefix                 ;          mov eax, %0                           ;          mov ebx, %1                           ;          att_syntax prefix                     ;          :                        //output          : r (lbl1), r (lbl2) //input          : %eax, %ebx);       //clobberWell, this is a nice way if you want to concentrate on the assembly code (which is how I do it when I optimize code by hand). Now, let me explain it a bit. First, you have two arrays containing the retrieved data, nothing fancy. Then you get the assembly code. If you're not familiar with inlined assembly I would recommend you this link, though I'll briefly go over my code.The __asm__ directive lets you insert assembly instructions anywhere in a code. At first I tell the assembler that I'll be using Intel's syntax (no % prefix for registers, ...), then I move the content of the register %0 in eax, and then the content of %1 in ebx (%0 is the pointer for lbl1, %1 is the pointer for lbl2). Then, I switch to AT&T syntax for the rest of the parameters. After the first : you can specify output variables. After the second : you can specify inputs. In here I passed lbl1 & lbl2 and I used r to let the compiler handle register allocation. You can specify the registers if you know what you're doing. After the last : you have to declare the registers used inside the code so that the compiler frees them & uses them for the remaining code generation steps.  