elf文件

发布时间 2023-08-05 08:44:51作者: 蓝天,白云

main.c(文件大小是100个字节)

int sum(int *a,int n);

int array[2] = {1,2};

int main()
{
    int val = sum(array,2);
    return val;
}

main.o(文件大小是1416个字节)

7f45 4c46 0201 0100 0000 0000 0000 0000
0100 3e00 0100 0000 0000 0000 0000 0000
0000 0000 0000 0000 4802 0000 0000 0000
0000 0000 4000 0000 0000 4000 0d00 0c00
f30f 1efa 4883 ec08 be02 0000 0048 8d3d
0000 0000 e800 0000 0048 83c4 08c3 0000
0100 0000 0200 0000 0047 4343 3a20 2855
6275 6e74 7520 3131 2e33 2e30 2d31 7562
756e 7475 317e 3232 2e30 3429 2031 312e
332e 3000 0000 0000 0400 0000 1000 0000
0500 0000 474e 5500 0200 00c0 0400 0000
0300 0000 0000 0000 1400 0000 0000 0000
017a 5200 0178 1001 1b0c 0708 9001 0000
1400 0000 1c00 0000 0000 0000 1e00 0000
0048 0e10 550e 0800 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0100 0000 0400 f1ff 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0300 0100
0000 0000 0000 0000 0000 0000 0000 0000
0800 0000 1200 0100 0000 0000 0000 0000
1e00 0000 0000 0000 0d00 0000 1100 0300
0000 0000 0000 0000 0800 0000 0000 0000
1300 0000 1000 0000 0000 0000 0000 0000
0000 0000 0000 0000 006d 6169 6e2e 6300
6d61 696e 0061 7272 6179 0073 756d 0000
1000 0000 0000 0000 0200 0000 0400 0000
fcff ffff ffff ffff 1500 0000 0000 0000
0400 0000 0500 0000 fcff ffff ffff ffff
2000 0000 0000 0000 0200 0000 0200 0000
0000 0000 0000 0000 002e 7379 6d74 6162
002e 7374 7274 6162 002e 7368 7374 7274
6162 002e 7265 6c61 2e74 6578 7400 2e64
6174 6100 2e62 7373 002e 636f 6d6d 656e
7400 2e6e 6f74 652e 474e 552d 7374 6163
6b00 2e6e 6f74 652e 676e 752e 7072 6f70
6572 7479 002e 7265 6c61 2e65 685f 6672
616d 6500 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 2000 0000 0100 0000
0600 0000 0000 0000 0000 0000 0000 0000
4000 0000 0000 0000 1e00 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0000 0000 0000 0000 1b00 0000 0400 0000
4000 0000 0000 0000 0000 0000 0000 0000
9001 0000 0000 0000 3000 0000 0000 0000
0a00 0000 0100 0000 0800 0000 0000 0000
1800 0000 0000 0000 2600 0000 0100 0000
0300 0000 0000 0000 0000 0000 0000 0000
6000 0000 0000 0000 0800 0000 0000 0000
0000 0000 0000 0000 0800 0000 0000 0000
0000 0000 0000 0000 2c00 0000 0800 0000
0300 0000 0000 0000 0000 0000 0000 0000
6800 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0000 0000 0000 0000 3100 0000 0100 0000
3000 0000 0000 0000 0000 0000 0000 0000
6800 0000 0000 0000 2c00 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0100 0000 0000 0000 3a00 0000 0100 0000
0000 0000 0000 0000 0000 0000 0000 0000
9400 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0000 0000 0000 0000 4a00 0000 0700 0000
0200 0000 0000 0000 0000 0000 0000 0000
9800 0000 0000 0000 2000 0000 0000 0000
0000 0000 0000 0000 0800 0000 0000 0000
0000 0000 0000 0000 6200 0000 0100 0000
0200 0000 0000 0000 0000 0000 0000 0000
b800 0000 0000 0000 3000 0000 0000 0000
0000 0000 0000 0000 0800 0000 0000 0000
0000 0000 0000 0000 5d00 0000 0400 0000
4000 0000 0000 0000 0000 0000 0000 0000
c001 0000 0000 0000 1800 0000 0000 0000
0a00 0000 0800 0000 0800 0000 0000 0000
1800 0000 0000 0000 0100 0000 0200 0000
0000 0000 0000 0000 0000 0000 0000 0000
e800 0000 0000 0000 9000 0000 0000 0000
0b00 0000 0300 0000 0800 0000 0000 0000
1800 0000 0000 0000 0900 0000 0300 0000
0000 0000 0000 0000 0000 0000 0000 0000
7801 0000 0000 0000 1700 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0000 0000 0000 0000 1100 0000 0300 0000
0000 0000 0000 0000 0000 0000 0000 0000
d801 0000 0000 0000 6c00 0000 0000 0000
0000 0000 0000 0000 0100 0000 0000 0000
0000 0000 0000 0000 

readelf -a main.o

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:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          584 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         13
  Section header string table index: 12

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       000000000000001e  0000000000000000  AX       0     0     1
  [ 2] .rela.text        RELA             0000000000000000  00000190
       0000000000000030  0000000000000018   I      10     1     8
  [ 3] .data             PROGBITS         0000000000000000  00000060
       0000000000000008  0000000000000000  WA       0     0     8
  [ 4] .bss              NOBITS           0000000000000000  00000068
       0000000000000000  0000000000000000  WA       0     0     1
  [ 5] .comment          PROGBITS         0000000000000000  00000068
       000000000000002c  0000000000000001  MS       0     0     1
  [ 6] .note.GNU-stack   PROGBITS         0000000000000000  00000094
       0000000000000000  0000000000000000           0     0     1
  [ 7] .note.gnu.pr[...] NOTE             0000000000000000  00000098
       0000000000000020  0000000000000000   A       0     0     8
  [ 8] .eh_frame         PROGBITS         0000000000000000  000000b8
       0000000000000030  0000000000000000   A       0     0     8
  [ 9] .rela.eh_frame    RELA             0000000000000000  000001c0
       0000000000000018  0000000000000018   I      10     8     8
  [10] .symtab           SYMTAB           0000000000000000  000000e8
       0000000000000090  0000000000000018          11     3     8
  [11] .strtab           STRTAB           0000000000000000  00000178
       0000000000000017  0000000000000000           0     0     1
  [12] .shstrtab         STRTAB           0000000000000000  000001d8
       000000000000006c  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), l (large), p (processor specific)

There are no section groups in this file.

There are no program headers in this file.

There is no dynamic section in this file.

Relocation section '.rela.text' at offset 0x190 contains 2 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000010  000400000002 R_X86_64_PC32     0000000000000000 array - 4
000000000015  000500000004 R_X86_64_PLT32    0000000000000000 sum - 4

Relocation section '.rela.eh_frame' at offset 0x1c0 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000020  000200000002 R_X86_64_PC32     0000000000000000 .text + 0
No processor specific unwind information to decode

Symbol table '.symtab' contains 6 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS main.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 .text
     3: 0000000000000000    30 FUNC    GLOBAL DEFAULT    1 main
     4: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    3 array
     5: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND sum

No version information found in this file.

Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 feature: IBT, SHSTK