I patched the binary to inject a shellcode, but it will break when I execute it

-1

I want to inject code into a binary, so the way that I tried is to add a section in the end of the file, and then add the whole program headers at the end of the file, then change the elf header's e_phoff, e_shnum, e_phnum, e_shoff.

Then add a str in .shstrtab section, add code in the end

this is some part of my code:

    def pack(self, d):
        res = ''
        for field_name, field_type in d._fields_:
            t = field_type
            i = getattr(d, field_name)
            if t == c_uint:
                res += struct.pack('I', i)
            elif t == c_ubyte:
                res += struct.pack('B', i)
            elif t == c_ulonglong:
                res += struct.pack('Q', i)
            elif t == c_ushort:
                res += struct.pack('H', i)
            else:
                try:
                    length = field_type._length_
                    for item in i:
                        res += struct.pack('b', item)
                except Exception as e:
                    print e
        return bytearray(res)

    def align(self, res):
        return (len(res)+15) & ~15

    def modifySectionHeader(self, s, l, sz=False):
        if sz == False:
            s.sh_offset += l
            if s.sh_addr != 0:
                s.sh_addr += l
        else:
            s.sh_size += l

    def add(self, res, c, f, r = None):
        if r == None:
            l = len(c)
            res[f:f+l] = c
            self.modifiedPos = f+l
        else:
            c += r
            self.add(res, c, f)

    def InsertOpcode(self, opcode):
        # make the length align to 0x10
        code_length = self.align(opcode)
        # I will add a section at the end of the file, and then add program header to the end
        # and then add a LOAD segment
        modifiedSize = len(self.bin) + \
            (len(self.programHeaders)+1)*self.elfHeader.e_phentsize + \
            code_length + self.elfHeader.e_shentsize
        self.modifiedBin = ['\x00' for _ in range(modifiedSize)]
        # pack function is to change ctypes struct into bytearray
        if self.mode == CS_MODE_64:
            tmpElfHeader = Elf64_Ehdr.from_buffer_copy(self.pack(self.elfHeader))
            addedSegment = Elf64_Phdr.from_buffer_copy(self.pack(self.getLOADSegment()))
            addedSection = Elf64_Shdr.from_buffer_copy(self.pack(self.findSectionByName('.text')))
        elif self.mode == CS_MODE_32:
            tmpElfHeader = Elf32_Ehdr.from_buffer_copy(self.pack(self.elfHeader))
            addedSegment = Elf32_Phdr.from_buffer_copy(self.pack(self.getLOADSegment()))
            addedSection = Elf32_Shdr.from_buffer_copy(self.pack(self.findSectionByName('.text')))

        tmpElfHeader.e_phoff = len(self.bin) + self.elfHeader.e_shentsize + 8
        tmpElfHeader.e_phnum += 1
        tmpElfHeader.e_shnum += 1
        tmpElfHeader.e_shoff += 8
        # add function is to add the bytearray of string into the third arg's point
        self.add(self.modifiedBin, self.pack(tmpElfHeader), 0)
        elfHeaderLength = len(self.pack(tmpElfHeader))
        shstrtab_idx = self.elfHeader.e_shstrndx
        shstrtab = self.sectionHeaders[shstrtab_idx]
        shstrtab_offset = shstrtab.sh_offset
        shstrtab_size = shstrtab.sh_size
        shstrtab.sh_size += 8
        self.add(self.modifiedBin, self.bin[elfHeaderLength:shstrtab_offset+shstrtab_size], self.modifiedPos)
        name_offset = self.modifiedPos
        # this is to add the new section's name
        self.add(self.modifiedBin, '.added'.ljust(8, '\x00'), self.modifiedPos)
        stop_offset = self.elfHeader.e_shoff + self.elfHeader.e_shentsize*shstrtab_idx
        #copy the rest of unchange bytes
        self.add(self.modifiedBin, self.bin[shstrtab_offset+shstrtab_size:stop_offset], self.modifiedPos)
        self.add(self.modifiedBin, self.pack(shstrtab), self.modifiedPos)
        # modify remained section's offset , make them +8
        for i in range(shstrtab_idx+1, len(self.sectionHeaders)):
            section = self.sectionHeaders[i]
            if section.sh_offset > shstrtab_offset:
                self.modifySectionHeader(section, 8)
            self.add(self.modifiedBin, self.pack(section), self.modifiedPos)
        code_offset = self.modifiedPos + tmpElfHeader.e_shentsize + tmpElfHeader.e_phnum * tmpElfHeader.e_phentsize
        addedSection.sh_offset = code_offset
        addedSection.sh_size = code_length
        code_address = (self.entry & ~0xfffff) + code_offset
        addedSection.sh_addr = code_address
        addedSection.sh_name = name_offset - shstrtab_offset
        # add the added section
        self.add(self.modifiedBin, self.pack(addedSection), self.modifiedPos)
        # add program headers
        for segment in self.programHeaders:
            self.add(self.modifiedBin, self.pack(segment), self.modifiedPos)
        addedSegment.p_offset = code_offset
        addedSegment.p_vaddr = code_address
        addedSegment.p_paddr = code_address
        addedSegment.p_filesz = code_length
        addedSegment.p_memsz = code_length
        addedSegment.p_align = 8
        # add the added segment
        self.add(self.modifiedBin, self.pack(addedSegment), self.modifiedPos)
        # add code
        self.add(self.modifiedBin, opcode.ljust(code_length, '\x00'), self.modifiedPos)
        with open('patch', 'wb') as f:
            f.write(bytearray(self.modifiedBin))

and then when i use gdb to run it, I got this:

pwndbg> r
Starting program: /home/dajun/home/dajun/CTFutils/pwntool/patch/patch 

Program received signal SIGSEGV, Segmentation fault.
elf_get_dynamic_info (temp=0x0, l=0x7f500d99f168) at get-dynamic-info.h:45
45  get-dynamic-info.h: No such file or directory.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
──────────────────────────────────────[ REGISTERS ]───────────────────────────────────────
 RAX  0x7f500d99efd0 (newname) —▸ 0x7f500d7787ac ◂— insb   byte ptr [rdi], dx /* 'ld-linux-x86-64.so.2' */
 RBX  0x7f500d99f168 ◂— 0x21a0
 RCX  0x6c
 RDX  0x602fc8
 RDI  0x4023d8 ◂— add    dword ptr [rax], eax
 RSI  0x7f500d7787ac ◂— insb   byte ptr [rdi], dx /* 'ld-linux-x86-64.so.2' */
 R8   0x4041a0
 R9   0x0
 R10  0x400401 (puts@plt+1) ◂— and    eax, 0x200c12
 R11  0x8e
 R12  0x1
 R13  0x0
 R14  0x7f500d99f020 (_dl_rtld_libname) —▸ 0x4023d8 ◂— add    dword ptr [rax], eax
 R15  0x7f500d7787ac ◂— insb   byte ptr [rdi], dx /* 'ld-linux-x86-64.so.2' */
 RBP  0x7ffc99b47270 ◂— 0xa /* '\n' */
 RSP  0x7ffc99b47190 ◂— 0x38000000380
 RIP  0x7f500d77a891 (dl_main+1713) ◂— mov    rax, qword ptr [rdx]
────────────────────────────────────────[ DISASM ]────────────────────────────────────────
 ► 0x7f500d77a891 <dl_main+1713>    mov    rax, qword ptr [rdx] <0x7f500d99efd0>
   0x7f500d77a894 <dl_main+1716>    lea    rcx, [rbx + 0x40]
   0x7f500d77a898 <dl_main+1720>    test   rax, rax
   0x7f500d77a89b <dl_main+1723>    je     dl_main+1858 <0x7f500d77a922>
    ↓
   0x7f500d77a922 <dl_main+1858>    mov    rax, qword ptr [rbx]
   0x7f500d77a925 <dl_main+1861>    test   rax, rax
   0x7f500d77a928 <dl_main+1864>    je     dl_main+1979 <0x7f500d77a99b>
    ↓
   0x7f500d77a99b <dl_main+1979>    mov    rax, qword ptr [rbx + 0xe0]
   0x7f500d77a9a2 <dl_main+1986>    test   rax, rax
   0x7f500d77a9a5 <dl_main+1989>    je     dl_main+2002 <0x7f500d77a9b2>
    ↓
   0x7f500d77a9b2 <dl_main+2002>    cmp    qword ptr [rbx + 0x78], 0
────────────────────────────────────────[ STACK ]─────────────────────────────────────────
00:0000│ rsp  0x7ffc99b47190 ◂— 0x38000000380
... ↓
05:0028│      0x7ffc99b471b8 —▸ 0x7ffc99b47200 ◂— 0x0
06:0030│      0x7ffc99b471c0 —▸ 0x7ffc99b47220 ◂— 0x0
07:0038│      0x7ffc99b471c8 ◂— 0x400000000a /* '\n' */
──────────────────────────────────────[ BACKTRACE ]───────────────────────────────────────
 ► f 0     7f500d77a891 dl_main+1713
   f 1     7f500d77a891 dl_main+1713
   f 2     7f500d7918ad _dl_sysdep_start+813
   f 3     7f500d779c2a _dl_start+634
   f 4     7f500d779c2a _dl_start+634
   f 5     7f500d778c38 _dl_start_user
   f 6                1
   f 7     7ffc99b4810e
   f 8                0
──────────────────────────────────────────────────────────────────────────────────────────
Program received signal SIGSEGV (fault address 0x602fc8)
pwndbg> 

And, elf reader of it is this:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400430
  Start of program headers:          8672 (bytes into file)
  Start of section headers:          6624 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         32
  Section header string table index: 28

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000400238  00000238
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             0000000000400254  00000254
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .note.gnu.build-i NOTE             0000000000400274  00000274
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .gnu.hash         GNU_HASH         0000000000400298  00000298
       000000000000001c  0000000000000000   A       5     0     8
  [ 5] .dynsym           DYNSYM           00000000004002b8  000002b8
       0000000000000060  0000000000000018   A       6     1     8
  [ 6] .dynstr           STRTAB           0000000000400318  00000318
       000000000000003d  0000000000000000   A       0     0     1
  [ 7] .gnu.version      VERSYM           0000000000400356  00000356
       0000000000000008  0000000000000002   A       5     0     2
  [ 8] .gnu.version_r    VERNEED          0000000000400360  00000360
       0000000000000020  0000000000000000   A       6     1     8
  [ 9] .rela.dyn         RELA             0000000000400380  00000380
       0000000000000018  0000000000000018   A       5     0     8
  [10] .rela.plt         RELA             0000000000400398  00000398
       0000000000000030  0000000000000018  AI       5    24     8
  [11] .init             PROGBITS         00000000004003c8  000003c8
       000000000000001a  0000000000000000  AX       0     0     4
  [12] .plt              PROGBITS         00000000004003f0  000003f0
       0000000000000030  0000000000000010  AX       0     0     16
  [13] .plt.got          PROGBITS         0000000000400420  00000420
       0000000000000008  0000000000000000  AX       0     0     8
  [14] .text             PROGBITS         0000000000400430  00000430
       0000000000000182  0000000000000000  AX       0     0     16
  [15] .fini             PROGBITS         00000000004005b4  000005b4
       0000000000000009  0000000000000000  AX       0     0     4
  [16] .rodata           PROGBITS         00000000004005c0  000005c0
       000000000000000a  0000000000000000   A       0     0     4
  [17] .eh_frame_hdr     PROGBITS         00000000004005cc  000005cc
       0000000000000034  0000000000000000   A       0     0     4
  [18] .eh_frame         PROGBITS         0000000000400600  00000600
       00000000000000f4  0000000000000000   A       0     0     8
  [19] .init_array       INIT_ARRAY       0000000000600e10  00000e10
       0000000000000008  0000000000000000  WA       0     0     8
  [20] .fini_array       FINI_ARRAY       0000000000600e18  00000e18
       0000000000000008  0000000000000000  WA       0     0     8
  [21] .jcr              PROGBITS         0000000000600e20  00000e20
       0000000000000008  0000000000000000  WA       0     0     8
  [22] .dynamic          DYNAMIC          0000000000600e28  00000e28
       00000000000001d0  0000000000000010  WA       6     0     8
  [23] .got              PROGBITS         0000000000600ff8  00000ff8
       0000000000000008  0000000000000008  WA       0     0     8
  [24] .got.plt          PROGBITS         0000000000601000  00001000
       0000000000000028  0000000000000008  WA       0     0     8
  [25] .data             PROGBITS         0000000000601028  00001028
       0000000000000010  0000000000000000  WA       0     0     8
  [26] .bss              NOBITS           0000000000601038  00001038
       0000000000000008  0000000000000000  WA       0     0     1
  [27] .comment          PROGBITS         0000000000000000  00001038
       0000000000000035  0000000000000001  MS       0     0     1
  [28] .shstrtab         STRTAB           0000000000000000  000018c8
       0000000000000114  0000000000000000           0     0     1
  [29] .symtab           SYMTAB           0000000000000000  00001070
       0000000000000648  0000000000000018          30    47     8
  [30] .strtab           STRTAB           0000000000000000  000016b8
       0000000000000210  0000000000000000           0     0     1
  [31] .added            PROGBITS         0000000000402410  00002410
       0000000000000010  0000000000000000  AX       0     0     16
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x000000000000001c 0x000000000000001c  R      1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x00000000000006f4 0x00000000000006f4  R E    200000
  LOAD           0x0000000000000e10 0x0000000000600e10 0x0000000000600e10
                 0x0000000000000228 0x0000000000000230  RW     200000
  DYNAMIC        0x0000000000000e28 0x0000000000600e28 0x0000000000600e28
                 0x00000000000001d0 0x00000000000001d0  RW     8
  NOTE           0x0000000000000254 0x0000000000400254 0x0000000000400254
                 0x0000000000000044 0x0000000000000044  R      4
  GNU_EH_FRAME   0x00000000000005cc 0x00000000004005cc 0x00000000004005cc
                 0x0000000000000034 0x0000000000000034  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     10
  GNU_RELRO      0x0000000000000e10 0x0000000000600e10 0x0000000000600e10
                 0x00000000000001f0 0x00000000000001f0  R      1
  LOAD           0x0000000000002410 0x0000000000402410 0x0000000000402410
                 0x0000000000000010 0x0000000000000010  R E    8

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .plt.got .text .fini .rodata .eh_frame_hdr .eh_frame 
   03     .init_array .fini_array .jcr .dynamic .got .got.plt .data .bss 
   04     .dynamic 
   05     .note.ABI-tag .note.gnu.build-id 
   06     .eh_frame_hdr 
   07     
   08     .init_array .fini_array .jcr .dynamic .got 
   09     .added 

Dynamic section at offset 0xe28 contains 24 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000c (INIT)               0x4003c8
 0x000000000000000d (FINI)               0x4005b4
 0x0000000000000019 (INIT_ARRAY)         0x600e10
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x600e18
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x400298
 0x0000000000000005 (STRTAB)             0x400318
 0x0000000000000006 (SYMTAB)             0x4002b8
 0x000000000000000a (STRSZ)              61 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x601000
 0x0000000000000002 (PLTRELSZ)           48 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x400398
 0x0000000000000007 (RELA)               0x400380
 0x0000000000000008 (RELASZ)             24 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x400360
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x400356
 0x0000000000000000 (NULL)               0x0

Relocation section '.rela.dyn' at offset 0x380 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000600ff8  000300000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0

Relocation section '.rela.plt' at offset 0x398 contains 2 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000601018  000100000007 R_X86_64_JUMP_SLO 0000000000000000 puts@GLIBC_2.2.5 + 0
000000601020  000200000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main@GLIBC_2.2.5 + 0

The decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported.

Symbol table '.dynsym' contains 4 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND puts@GLIBC_2.2.5 (2)
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (2)
     3: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__

Symbol table '.symtab' contains 67 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000400238     0 SECTION LOCAL  DEFAULT    1 
     2: 0000000000400254     0 SECTION LOCAL  DEFAULT    2 
     3: 0000000000400274     0 SECTION LOCAL  DEFAULT    3 
     4: 0000000000400298     0 SECTION LOCAL  DEFAULT    4 
     5: 00000000004002b8     0 SECTION LOCAL  DEFAULT    5 
     6: 0000000000400318     0 SECTION LOCAL  DEFAULT    6 
     7: 0000000000400356     0 SECTION LOCAL  DEFAULT    7 
     8: 0000000000400360     0 SECTION LOCAL  DEFAULT    8 
     9: 0000000000400380     0 SECTION LOCAL  DEFAULT    9 
    10: 0000000000400398     0 SECTION LOCAL  DEFAULT   10 
    11: 00000000004003c8     0 SECTION LOCAL  DEFAULT   11 
    12: 00000000004003f0     0 SECTION LOCAL  DEFAULT   12 
    13: 0000000000400420     0 SECTION LOCAL  DEFAULT   13 
    14: 0000000000400430     0 SECTION LOCAL  DEFAULT   14 
    15: 00000000004005b4     0 SECTION LOCAL  DEFAULT   15 
    16: 00000000004005c0     0 SECTION LOCAL  DEFAULT   16 
    17: 00000000004005cc     0 SECTION LOCAL  DEFAULT   17 
    18: 0000000000400600     0 SECTION LOCAL  DEFAULT   18 
    19: 0000000000600e10     0 SECTION LOCAL  DEFAULT   19 
    20: 0000000000600e18     0 SECTION LOCAL  DEFAULT   20 
    21: 0000000000600e20     0 SECTION LOCAL  DEFAULT   21 
    22: 0000000000600e28     0 SECTION LOCAL  DEFAULT   22 
    23: 0000000000600ff8     0 SECTION LOCAL  DEFAULT   23 
    24: 0000000000601000     0 SECTION LOCAL  DEFAULT   24 
    25: 0000000000601028     0 SECTION LOCAL  DEFAULT   25 
    26: 0000000000601038     0 SECTION LOCAL  DEFAULT   26 
    27: 0000000000000000     0 SECTION LOCAL  DEFAULT   27 
    28: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    29: 0000000000600e20     0 OBJECT  LOCAL  DEFAULT   21 __JCR_LIST__
    30: 0000000000400460     0 FUNC    LOCAL  DEFAULT   14 deregister_tm_clones
    31: 00000000004004a0     0 FUNC    LOCAL  DEFAULT   14 register_tm_clones
    32: 00000000004004e0     0 FUNC    LOCAL  DEFAULT   14 __do_global_dtors_aux
    33: 0000000000601038     1 OBJECT  LOCAL  DEFAULT   26 completed.7594
    34: 0000000000600e18     0 OBJECT  LOCAL  DEFAULT   20 __do_global_dtors_aux_fin
    35: 0000000000400500     0 FUNC    LOCAL  DEFAULT   14 frame_dummy
    36: 0000000000600e10     0 OBJECT  LOCAL  DEFAULT   19 __frame_dummy_init_array_
    37: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS a.c
    38: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    39: 00000000004006f0     0 OBJECT  LOCAL  DEFAULT   18 __FRAME_END__
    40: 0000000000600e20     0 OBJECT  LOCAL  DEFAULT   21 __JCR_END__
    41: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
    42: 0000000000600e18     0 NOTYPE  LOCAL  DEFAULT   19 __init_array_end
    43: 0000000000600e28     0 OBJECT  LOCAL  DEFAULT   22 _DYNAMIC
    44: 0000000000600e10     0 NOTYPE  LOCAL  DEFAULT   19 __init_array_start
    45: 00000000004005cc     0 NOTYPE  LOCAL  DEFAULT   17 __GNU_EH_FRAME_HDR
    46: 0000000000601000     0 OBJECT  LOCAL  DEFAULT   24 _GLOBAL_OFFSET_TABLE_
    47: 00000000004005b0     2 FUNC    GLOBAL DEFAULT   14 __libc_csu_fini
    48: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTab
    49: 0000000000601028     0 NOTYPE  WEAK   DEFAULT   25 data_start
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND puts@@GLIBC_2.2.5
    51: 0000000000601038     0 NOTYPE  GLOBAL DEFAULT   25 _edata
    52: 00000000004005b4     0 FUNC    GLOBAL DEFAULT   15 _fini
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
    54: 0000000000601028     0 NOTYPE  GLOBAL DEFAULT   25 __data_start
    55: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    56: 0000000000601030     0 OBJECT  GLOBAL HIDDEN    25 __dso_handle
    57: 00000000004005c0     4 OBJECT  GLOBAL DEFAULT   16 _IO_stdin_used
    58: 0000000000400540   101 FUNC    GLOBAL DEFAULT   14 __libc_csu_init
    59: 0000000000601040     0 NOTYPE  GLOBAL DEFAULT   26 _end
    60: 0000000000400430    42 FUNC    GLOBAL DEFAULT   14 _start
    61: 0000000000601038     0 NOTYPE  GLOBAL DEFAULT   26 __bss_start
    62: 0000000000400526    21 FUNC    GLOBAL DEFAULT   14 main
    63: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
    64: 0000000000601038     0 OBJECT  GLOBAL HIDDEN    25 __TMC_END__
    65: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable
    66: 00000000004003c8     0 FUNC    GLOBAL DEFAULT   11 _init

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 0000000000400356  Offset: 0x000356  Link: 5 (.dynsym)
  000:   0 (*local*)       2 (GLIBC_2.2.5)   2 (GLIBC_2.2.5)   0 (*local*)    

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x0000000000400360  Offset: 0x000360  Link: 6 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 1
  0x0010:   Name: GLIBC_2.2.5  Flags: none  Version: 2

Displaying notes found at file offset 0x00000254 with length 0x00000020:
  Owner                 Data size   Description
  GNU                  0x00000010   NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 2.6.32

Displaying notes found at file offset 0x00000274 with length 0x00000024:
  Owner                 Data size   Description
  GNU                  0x00000014   NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: e8d2cdec6ef9916addf2f088fed34c077c3a319f

Everything seems to be correct, but I just can't run it

I need help

linux
elf
asked on Stack Overflow Nov 17, 2019 by YvG3

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0