read link-load-library

 -s, --full-contents      Display the full contents of all sections requested
show code as section.
  1 (my_env) moonx@moonx:chapter7$ objdump -s program1
  2 
  3 program1:     文件格式 elf64-x86-64
  4 
  5 Contents of section .interp:
  6  400238 2f6c6962 36342f6c 642d6c69 6e75782d  /lib64/ld-linux-
  7  400248 7838362d 36342e73 6f2e3200           x86-64.so.2.    
  8 Contents of section .note.ABI-tag:
  9  400254 04000000 10000000 01000000 474e5500  ............GNU.
 10  400264 00000000 02000000 06000000 20000000  ............ ...
 11 Contents of section .note.gnu.build-id:
 12  400274 04000000 14000000 03000000 474e5500  ............GNU.
 13  400284 62f31a3f cf706e39 4fe640e3 efa2d3a3  b..?.pn9O.@.....
 14  400294 06a5f8a7                             ....            
 15 Contents of section .gnu.hash:
 16  400298 03000000 07000000 01000000 06000000  ................
 17  4002a8 88c02001 00044009 07000000 09000000  .. ...@.........
 18  4002b8 0b000000 4245d5ec bbe3927c d871581c  ....BE.....|.qX.
 19  4002c8 b98df10e ebd3ef0e                    ........        
 20 Contents of section .dynsym:
 21  4002d0 00000000 00000000 00000000 00000000  ................
 22  4002e0 00000000 00000000 08000000 20000000  ............ ...
 23  4002f0 00000000 00000000 00000000 00000000  ................
 24  400300 6d000000 12000000 00000000 00000000  m...............
 25  400310 00000000 00000000 7e000000 12000000  ........~.......
 26  400320 00000000 00000000 00000000 00000000  ................
 27  400330 24000000 20000000 00000000 00000000  $... ...........
 28  400340 00000000 00000000 33000000 20000000  ........3... ...
 29  400350 00000000 00000000 00000000 00000000  ................
 30  400360 47000000 20000000 00000000 00000000  G... ...........
 31  400370 00000000 00000000 90000000 10001900  ................
 32  400380 38106000 00000000 00000000 00000000  8.`.............
 33  400390 a3000000 10001a00 40106000 00000000  ........@.`.....
 34  4003a0 00000000 00000000 97000000 10001a00  ................
 35  4003b0 38106000 00000000 00000000 00000000  8.`.............
 36  4003c0 61000000 12000b00 28054000 00000000  a.......(.@.....
 37  4003d0 00000000 00000000 67000000 12000f00  ........g.......
 38  4003e0 14074000 00000000 00000000 00000000  ..@.............
 39 Contents of section .dynstr:
 40  4003f0 006c6962 2e736f00 5f49544d 5f646572  .lib.so._ITM_der
 41  400400 65676973 74657254 4d436c6f 6e655461  egisterTMCloneTa
 42  400410 626c6500 5f5f676d 6f6e5f73 74617274  ble.__gmon_start
 43  400420 5f5f005f 4a765f52 65676973 74657243  __._Jv_RegisterC
 44  400430 6c617373 6573005f 49544d5f 72656769  lasses._ITM_regi
 45  400440 73746572 544d436c 6f6e6554 61626c65  sterTMCloneTable
 46  400450 005f696e 6974005f 66696e69 00666f6f  ._init._fini.foo
 47  400460 62617200 6c696263 2e736f2e 36005f5f  bar.libc.so.6.__
 48  400470 6c696263 5f737461 72745f6d 61696e00  libc_start_main.
 49  400480 5f656461 7461005f 5f627373 5f737461  _edata.__bss_sta
 50  400490 7274005f 656e6400 474c4942 435f322e  rt._end.GLIBC_2.
 51  4004a0 322e3500                             2.5.            
 52 Contents of section .gnu.version:
 53  4004a4 00000000 00000200 00000000 00000100  ................
 54  4004b4 01000100 01000100                    ........        
 55 Contents of section .gnu.version_r:
 56  4004c0 01000100 74000000 10000000 00000000  ....t...........
 57  4004d0 751a6909 00000200 a8000000 00000000  u.i.............
 58 Contents of section .rela.dyn:
 59  4004e0 f80f6000 00000000 06000000 04000000  ..`.............
 60  4004f0 00000000 00000000                    ........        
 61 Contents of section .rela.plt:
 62  4004f8 18106000 00000000 07000000 02000000  ..`.............
 63  400508 00000000 00000000 20106000 00000000  ........ .`.....
 64  400518 07000000 03000000 00000000 00000000  ................
 65 Contents of section .init:
 66  400528 4883ec08 488b05c5 0a200048 85c07405  H...H.... .H..t.
 67  400538 e8430000 004883c4 08c3               .C...H....      
 68 Contents of section .plt:
 69  400550 ff35b20a 2000ff25 b40a2000 0f1f4000  .5.. ..%.. ...@.
 70  400560 ff25b20a 20006800 000000e9 e0ffffff  .%.. .h.........
 71  400570 ff25aa0a 20006801 000000e9 d0ffffff  .%.. .h.........
 72 Contents of section .plt.got:
 73  400580 ff25720a 20006690                    .%r. .f.        
 74 Contents of section .text:
 75  400590 31ed4989 d15e4889 e24883e4 f0505449  1.I..^H..H...PTI
 76  4005a0 c7c01007 400048c7 c1a00640 0048c7c7  ....@.H....@.H..
 77  4005b0 86064000 e8b7ffff fff4660f 1f440000  ..@.......f..D..
 78  4005c0 b83f1060 0055482d 38106000 4883f80e  .?.`.UH-8.`.H...
 79  4005d0 4889e576 1bb80000 00004885 c074115d  H..v......H..t.]
 80  4005e0 bf381060 00ffe066 0f1f8400 00000000  .8.`...f........
 81  4005f0 5dc30f1f 4000662e 0f1f8400 00000000  ]...@.f.........
 82  400600 be381060 00554881 ee381060 0048c1fe  .8.`.UH..8.`.H..
 83  400610 034889e5 4889f048 c1e83f48 01c648d1  .H..H..H..?H..H.
 84  400620 fe7415b8 00000000 4885c074 0b5dbf38  .t......H..t.].8
 85  400630 106000ff e00f1f00 5dc3660f 1f440000  .`......].f..D..
 86  400640 803df109 20000075 11554889 e5e86eff  .=.. ..u.UH...n.
 87  400650 ffff5dc6 05de0920 0001f3c3 0f1f4000  ..].... ......@.
 88  400660 bf100e60 0048833f 007505eb 930f1f00  ...`.H.?.u......
 89  400670 b8000000 004885c0 74f15548 89e5ffd0  .....H..t.UH....
 90  400680 5de97aff ffff5548 89e5bf01 000000e8  ].z...UH........
 91  400690 ccfeffff b8000000 005dc30f 1f440000  .........]...D..
 92  4006a0 41574156 4189ff41 5541544c 8d254e07  AWAVA..AUATL.%N.
 93  4006b0 20005548 8d2d4e07 20005349 89f64989   .UH.-N. .SI..I.
 94  4006c0 d54c29e5 4883ec08 48c1fd03 e857feff  .L).H...H....W..
 95  4006d0 ff4885ed 742031db 0f1f8400 00000000  .H..t 1.........
 96  4006e0 4c89ea4c 89f64489 ff41ff14 dc4883c3  L..L..D..A...H..
 97  4006f0 014839eb 75ea4883 c4085b5d 415c415d  .H9.u.H...[]AA]
 98  400700 415e415f c390662e 0f1f8400 00000000  A^A_..f.........
 99  400710 f3c3                                 ..              
100 Contents of section .fini:
101  400714 4883ec08 4883c408 c3                 H...H....       
102 Contents of section .rodata:
103  400720 01000200                             ....            
104 Contents of section .eh_frame_hdr:
105  400724 011b033b 30000000 05000000 2cfeffff  ...;0.......,...
106  400734 7c000000 6cfeffff 4c000000 62ffffff  |...l...L...b...
107  400744 a4000000 7cffffff c4000000 ecffffff  ....|...........
108  400754 0c010000                             ....            
109 Contents of section .eh_frame:
110  400758 14000000 00000000 017a5200 01781001  .........zR..x..
111  400768 1b0c0708 90010710 14000000 1c000000  ................
112  400778 18feffff 2a000000 00000000 00000000  ....*...........
113  400788 14000000 00000000 017a5200 01781001  .........zR..x..
114  400798 1b0c0708 90010000 24000000 1c000000  ........$.......
115  4007a8 a8fdffff 30000000 000e1046 0e184a0f  ....0......F..J.
116  4007b8 0b770880 003f1a3b 2a332422 00000000  .w...?.;*3$"....
117  4007c8 1c000000 44000000 b6feffff 15000000  ....D...........
118  4007d8 00410e10 8602430d 06500c07 08000000  .A....C..P......
119  4007e8 44000000 64000000 b0feffff 65000000  D...d.......e...
120  4007f8 00420e10 8f02420e 188e0345 0e208d04  .B....B....E. ..
121  400808 420e288c 05480e30 8606480e 3883074d  B.(..H.0..H.8..M
122  400818 0e40720e 38410e30 410e2842 0e20420e  .@r.8A.0A.(B. B.
123  400828 18420e10 420e0800 14000000 ac000000  .B..B...........
124  400838 d8feffff 02000000 00000000 00000000  ................
125  400848 00000000                             ....            
126 Contents of section .init_array:
127  600e00 60064000 00000000                    `.@.....        
128 Contents of section .fini_array:
129  600e08 40064000 00000000                    @.@.....        
130 Contents of section .jcr:
131  600e10 00000000 00000000                    ........        
132 Contents of section .dynamic:
133  600e18 01000000 00000000 01000000 00000000  ................
134  600e28 01000000 00000000 74000000 00000000  ........t.......
135  600e38 0c000000 00000000 28054000 00000000  ........(.@.....
136  600e48 0d000000 00000000 14074000 00000000  ..........@.....
137  600e58 19000000 00000000 000e6000 00000000  ..........`.....
138  600e68 1b000000 00000000 08000000 00000000  ................
139  600e78 1a000000 00000000 080e6000 00000000  ..........`.....
140  600e88 1c000000 00000000 08000000 00000000  ................
141  600e98 f5feff6f 00000000 98024000 00000000  ...o......@.....
142  600ea8 05000000 00000000 f0034000 00000000  ..........@.....
143  600eb8 06000000 00000000 d0024000 00000000  ..........@.....
144  600ec8 0a000000 00000000 b4000000 00000000  ................
145  600ed8 0b000000 00000000 18000000 00000000  ................
146  600ee8 15000000 00000000 00000000 00000000  ................
147  600ef8 03000000 00000000 00106000 00000000  ..........`.....
148  600f08 02000000 00000000 30000000 00000000  ........0.......
149  600f18 14000000 00000000 07000000 00000000  ................
150  600f28 17000000 00000000 f8044000 00000000  ..........@.....
151  600f38 07000000 00000000 e0044000 00000000  ..........@.....
152  600f48 08000000 00000000 18000000 00000000  ................
153  600f58 09000000 00000000 18000000 00000000  ................
154  600f68 feffff6f 00000000 c0044000 00000000  ...o......@.....
155  600f78 ffffff6f 00000000 01000000 00000000  ...o............
156  600f88 f0ffff6f 00000000 a4044000 00000000  ...o......@.....
157  600f98 00000000 00000000 00000000 00000000  ................
158  600fa8 00000000 00000000 00000000 00000000  ................
159  600fb8 00000000 00000000 00000000 00000000  ................
160  600fc8 00000000 00000000 00000000 00000000  ................
161  600fd8 00000000 00000000 00000000 00000000  ................
162  600fe8 00000000 00000000 00000000 00000000  ................
163 Contents of section .got:
164  600ff8 00000000 00000000                    ........        
165 Contents of section .got.plt:
166  601000 180e6000 00000000 00000000 00000000  ..`.............
167  601010 00000000 00000000 66054000 00000000  ........f.@.....
168  601020 76054000 00000000                    v.@.....        
169 Contents of section .data:
170  601028 00000000 00000000 00000000 00000000  ................
171 Contents of section .comment:
172  0000 4743433a 20285562 756e7475 20352e34  GCC: (Ubuntu 5.4
173  0010 2e302d36 7562756e 7475317e 31362e30  .0-6ubuntu1~16.0
174  0020 342e3131 2920352e 342e3020 32303136  4.11) 5.4.0 2016
175  0030 30363039 00                          0609.  
(my_env) moonx@moonx:chapter7$ objdump -s program1
Contents of section .interp:   this section save the ld's path 
Before this job, you should make a back-up your original .so file.
Following command may destroy your files.

open your library with vi editor.
Here, the target is not .so file.
As .so is a symbolic link in general, you have to find an original destination file.
enter :%!xxd
This command changes file display format from binary to hex and ASCII.
modify what you want, that is, text.
You must modify on the left, Hex code, not right side, ASCII chars.
You must not insert or delete characters, only replace them. You can't make a string longer. You can make a string shorter by putting nul characters (press Ctrl+V Ctrl+@) at the end.
After modification, enter :%!xxd -r
It will recover display format into binary.
save your file and exit, by entering :wq.
how to dive into BIN file

chapter 2 compile and link

 The picture above show the four steps in gcc work process.

step1: propressing  => gcc -E hello.c -o hello.i (-E means only do propress.)

Propress mainly deal with the instructions starting with "#".

step2: compilation => gcc -S hello.i -o hello.s 

compilation mainly do the grammer analyze and generate the assemble code.

step3: assembly => gcc -c hello.s -o hello.o

assembly mainly convert the assemble code into machine instructions.

step4: linking => mainly linker the obj into executable. with relocation.

/usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccmYH2zM.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. /tmp/ccWAxdN7.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o

moonx@moonx:test$ file *
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=57cc2437bbe727def73a48bec461e359d64869da, not stripped
hello.c: C source, ASCII text
hello.i: C source, ASCII text
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
hello.s: assembler source, ASCII text  

moonx@moonx:test$ gcc hello.c -o hello --verbose
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 
COLLECT_GCC_OPTIONS='-o' 'hello' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1 -quiet -v -imultiarch x86_64-linux-gnu hello.c -quiet -dumpbase hello.c -mtune=generic -march=x86-64 -auxbase hello -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccr5QOBH.s
GNU C11 (Ubuntu 5.4.0-6ubuntu1~16.04.11) version 5.4.0 20160609 (x86_64-linux-gnu)
    compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/5/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C11 (Ubuntu 5.4.0-6ubuntu1~16.04.11) version 5.4.0 20160609 (x86_64-linux-gnu)
    compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5f69ca549f086e2c3748f9d1423a4dee
COLLECT_GCC_OPTIONS='-o' 'hello' '-v' '-mtune=generic' '-march=x86-64'
 as -v --64 -o /tmp/cczp4a7U.o /tmp/ccr5QOBH.s
GNU汇编版本 2.26.1 (x86_64-linux-gnu) 使用BFD版本 (GNU Binutils for Ubuntu) 2.26.1
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'hello' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccbkbaD8.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o hello /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. /tmp/cczp4a7U.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o
gcc hello.c -o hello --verbose

chapter 3 what in obj

objdump - display information from object files.

moonx@moonx:chapter3$ objdump -h simple_section.o 

simple_section.o:     文件格式 elf64-x86-64

节:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00000055  0000000000000000  0000000000000000  00000040  2**0
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000008  0000000000000000  0000000000000000  00000098  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000008  0000000000000000  0000000000000000  000000a0  2**2
                  ALLOC
  3 .rodata       00000004  0000000000000000  0000000000000000  000000a0  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .comment      00000036  0000000000000000  0000000000000000  000000a4  2**0
                  CONTENTS, READONLY
  5 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000000da  2**0
                  CONTENTS, READONLY
  6 .eh_frame     00000058  0000000000000000  0000000000000000  000000e0  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
objdump -h simple_section.o  -h, --[section-]headers
moonx@moonx:chapter3$ objdump -s -d simple_section.o 

simple_section.o:     文件格式 elf64-x86-64

Contents of section .text:
 0000 554889e5 4883ec10 897dfc8b 45fc89c6  UH..H....}..E...
 0010 bf000000 00b80000 0000e800 00000090  ................
 0020 c9c35548 89e54883 ec10c745 f8010000  ..UH..H....E....
 0030 008b1500 0000008b 05000000 0001c28b  ................
 0040 45f801c2 8b45fc01 d089c7e8 00000000  E....E..........
 0050 8b45f8c9 c3                          .E...           
Contents of section .data:
 0000 54000000 55000000                    T...U...        
Contents of section .rodata:
 0000 25640a00                             %d..            
Contents of section .comment:
 0000 00474343 3a202855 62756e74 7520352e  .GCC: (Ubuntu 5.
 0010 342e302d 36756275 6e747531 7e31362e  4.0-6ubuntu1~16.
 0020 30342e31 31292035 2e342e30 20323031  04.11) 5.4.0 201
 0030 36303630 3900                        60609.          
Contents of section .eh_frame:
 0000 14000000 00000000 017a5200 01781001  .........zR..x..
 0010 1b0c0708 90010000 1c000000 1c000000  ................
 0020 00000000 22000000 00410e10 8602430d  ...."....A....C.
 0030 065d0c07 08000000 1c000000 3c000000  .]..........<...
 0040 00000000 33000000 00410e10 8602430d  ....3....A....C.
 0050 066e0c07 08000000                    .n......        

Disassembly of section .text:

0000000000000000 <func1>:
   0:    55                       push   %rbp
   1:    48 89 e5                 mov    %rsp,%rbp
   4:    48 83 ec 10              sub    $0x10,%rsp
   8:    89 7d fc                 mov    %edi,-0x4(%rbp)
   b:    8b 45 fc                 mov    -0x4(%rbp),%eax
   e:    89 c6                    mov    %eax,%esi
  10:    bf 00 00 00 00           mov    $0x0,%edi
  15:    b8 00 00 00 00           mov    $0x0,%eax
  1a:    e8 00 00 00 00           callq  1f <func1+0x1f>
  1f:    90                       nop
  20:    c9                       leaveq 
  21:    c3                       retq   

0000000000000022 <main>:
  22:    55                       push   %rbp
  23:    48 89 e5                 mov    %rsp,%rbp
  26:    48 83 ec 10              sub    $0x10,%rsp
  2a:    c7 45 f8 01 00 00 00     movl   $0x1,-0x8(%rbp)
  31:    8b 15 00 00 00 00        mov    0x0(%rip),%edx        # 37 <main+0x15>
  37:    8b 05 00 00 00 00        mov    0x0(%rip),%eax        # 3d <main+0x1b>
  3d:    01 c2                    add    %eax,%edx
  3f:    8b 45 f8                 mov    -0x8(%rbp),%eax
  42:    01 c2                    add    %eax,%edx
  44:    8b 45 fc                 mov    -0x4(%rbp),%eax
  47:    01 d0                    add    %edx,%eax
  49:    89 c7                    mov    %eax,%edi
  4b:    e8 00 00 00 00           callq  50 <main+0x2e>
  50:    8b 45 f8                 mov    -0x8(%rbp),%eax
  53:    c9                       leaveq 
  54:    c3                       retq   
objdump -s -d simple_section.o  -s, --full-contents -d, --disassemble
moonx@moonx:chapter3$ objdump -x -s -d simple_section.o 

simple_section.o:     文件格式 elf64-x86-64
simple_section.o
体系结构:i386:x86-64, 标志 0x00000011:
HAS_RELOC, HAS_SYMS
起始地址 0x0000000000000000

节:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00000055  0000000000000000  0000000000000000  00000040  2**0
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000008  0000000000000000  0000000000000000  00000098  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000008  0000000000000000  0000000000000000  000000a0  2**2
                  ALLOC
  3 .rodata       00000004  0000000000000000  0000000000000000  000000a0  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .comment      00000036  0000000000000000  0000000000000000  000000a4  2**0
                  CONTENTS, READONLY
  5 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000000da  2**0
                  CONTENTS, READONLY
  6 .eh_frame     00000058  0000000000000000  0000000000000000  000000e0  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
SYMBOL TABLE:
0000000000000000 l    df *ABS*    0000000000000000 simple_section.c
0000000000000000 l    d  .text    0000000000000000 .text
0000000000000000 l    d  .data    0000000000000000 .data
0000000000000000 l    d  .bss    0000000000000000 .bss
0000000000000000 l     O .bss    0000000000000004 global_static_var
0000000000000000 l    d  .rodata    0000000000000000 .rodata
0000000000000004 l     O .data    0000000000000004 static_var.1842
0000000000000004 l     O .bss    0000000000000004 static_var2.1843
0000000000000000 l    d  .note.GNU-stack    0000000000000000 .note.GNU-stack
0000000000000000 l    d  .eh_frame    0000000000000000 .eh_frame
0000000000000000 l    d  .comment    0000000000000000 .comment
0000000000000000 g     O .data    0000000000000004 global_init_var
0000000000000004       O *COM*    0000000000000004 global_uninit_var
0000000000000000 g     F .text    0000000000000022 func1
0000000000000000         *UND*    0000000000000000 printf
0000000000000022 g     F .text    0000000000000033 main


Contents of section .text:
 0000 554889e5 4883ec10 897dfc8b 45fc89c6  UH..H....}..E...
 0010 bf000000 00b80000 0000e800 00000090  ................
 0020 c9c35548 89e54883 ec10c745 f8010000  ..UH..H....E....
 0030 008b1500 0000008b 05000000 0001c28b  ................
 0040 45f801c2 8b45fc01 d089c7e8 00000000  E....E..........
 0050 8b45f8c9 c3                          .E...           
Contents of section .data:
 0000 54000000 55000000                    T...U...        
Contents of section .rodata:
 0000 25640a00                             %d..            
Contents of section .comment:
 0000 00474343 3a202855 62756e74 7520352e  .GCC: (Ubuntu 5.
 0010 342e302d 36756275 6e747531 7e31362e  4.0-6ubuntu1~16.
 0020 30342e31 31292035 2e342e30 20323031  04.11) 5.4.0 201
 0030 36303630 3900                        60609.          
Contents of section .eh_frame:
 0000 14000000 00000000 017a5200 01781001  .........zR..x..
 0010 1b0c0708 90010000 1c000000 1c000000  ................
 0020 00000000 22000000 00410e10 8602430d  ...."....A....C.
 0030 065d0c07 08000000 1c000000 3c000000  .]..........<...
 0040 00000000 33000000 00410e10 8602430d  ....3....A....C.
 0050 066e0c07 08000000                    .n......        

Disassembly of section .text:

0000000000000000 <func1>:
   0:    55                       push   %rbp
   1:    48 89 e5                 mov    %rsp,%rbp
   4:    48 83 ec 10              sub    $0x10,%rsp
   8:    89 7d fc                 mov    %edi,-0x4(%rbp)
   b:    8b 45 fc                 mov    -0x4(%rbp),%eax
   e:    89 c6                    mov    %eax,%esi
  10:    bf 00 00 00 00           mov    $0x0,%edi
            11: R_X86_64_32    .rodata
  15:    b8 00 00 00 00           mov    $0x0,%eax
  1a:    e8 00 00 00 00           callq  1f <func1+0x1f>
            1b: R_X86_64_PC32    printf-0x4
  1f:    90                       nop
  20:    c9                       leaveq 
  21:    c3                       retq   

0000000000000022 <main>:
  22:    55                       push   %rbp
  23:    48 89 e5                 mov    %rsp,%rbp
  26:    48 83 ec 10              sub    $0x10,%rsp
  2a:    c7 45 f8 01 00 00 00     movl   $0x1,-0x8(%rbp)
  31:    8b 15 00 00 00 00        mov    0x0(%rip),%edx        # 37 <main+0x15>
            33: R_X86_64_PC32    .data
  37:    8b 05 00 00 00 00        mov    0x0(%rip),%eax        # 3d <main+0x1b>
            39: R_X86_64_PC32    .bss
  3d:    01 c2                    add    %eax,%edx
  3f:    8b 45 f8                 mov    -0x8(%rbp),%eax
  42:    01 c2                    add    %eax,%edx
  44:    8b 45 fc                 mov    -0x4(%rbp),%eax
  47:    01 d0                    add    %edx,%eax
  49:    89 c7                    mov    %eax,%edi
  4b:    e8 00 00 00 00           callq  50 <main+0x2e>
            4c: R_X86_64_PC32    func1-0x4
  50:    8b 45 f8                 mov    -0x8(%rbp),%eax
  53:    c9                       leaveq 
  54:    c3                       retq   
objdump -x -s -d simple_section.o -x, --all-headers
moonx@moonx:chapter3$ objdump -t simple_section.o 

simple_section.o:     文件格式 elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*    0000000000000000 simple_section.c
0000000000000000 l    d  .text    0000000000000000 .text
0000000000000000 l    d  .data    0000000000000000 .data
0000000000000000 l    d  .bss    0000000000000000 .bss
0000000000000000 l     O .bss    0000000000000004 global_static_var
0000000000000000 l    d  .rodata    0000000000000000 .rodata
0000000000000004 l     O .data    0000000000000004 static_var.1842
0000000000000004 l     O .bss    0000000000000004 static_var2.1843
0000000000000000 l    d  .note.GNU-stack    0000000000000000 .note.GNU-stack
0000000000000000 l    d  .eh_frame    0000000000000000 .eh_frame
0000000000000000 l    d  .comment    0000000000000000 .comment
0000000000000000 g     O .data    0000000000000004 global_init_var
0000000000000004       O *COM*    0000000000000004 global_uninit_var
0000000000000000 g     F .text    0000000000000022 func1
0000000000000000         *UND*    0000000000000000 printf
0000000000000022 g     F .text    0000000000000033 main
objdump -t simple_section.o  -t, --syms Display the contents of the symbol table(s)
readelf - Displays information about ELF files.
moonx@moonx:chapter3$ readelf -h simple_section.o 
ELF 头:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  类别:                              ELF64
  数据:                              2 补码,小端序 (little endian)
  版本:                              1 (current)
  OS/ABI:                            UNIX - System V
  ABI 版本:                          0
  类型:                              REL (可重定位文件)
  系统架构:                          Advanced Micro Devices X86-64
  版本:                              0x1
  入口点地址:               0x0
  程序头起点:          0 (bytes into file)
  Start of section headers:          1120 (bytes into file)
  标志:             0x0
  本头的大小:       64 (字节)
  程序头大小:       0 (字节)
  Number of program headers:         0
  节头大小:         64 (字节)
  节头数量:         13
  字符串表索引节头: 10
readelf -h simple_section.o  -h --file-header       Display the ELF file header

ELF structure and constvar defines in "/usr/include/elf.h"

moonx@moonx:chapter3$ readelf -S simple_section.o 
共有 13 个节头,从偏移量 0x460 开始:

节头:
  [号] 名称              类型             地址              偏移量
       大小              全体大小          旗标   链接   信息   对齐
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000055  0000000000000000  AX       0     0     1
  [ 2] .rela.text        RELA             0000000000000000  00000350
       0000000000000078  0000000000000018   I      11     1     8
  [ 3] .data             PROGBITS         0000000000000000  00000098
       0000000000000008  0000000000000000  WA       0     0     4
  [ 4] .bss              NOBITS           0000000000000000  000000a0
       0000000000000008  0000000000000000  WA       0     0     4
  [ 5] .rodata           PROGBITS         0000000000000000  000000a0
       0000000000000004  0000000000000000   A       0     0     1
  [ 6] .comment          PROGBITS         0000000000000000  000000a4
       0000000000000036  0000000000000001  MS       0     0     1
  [ 7] .note.GNU-stack   PROGBITS         0000000000000000  000000da
       0000000000000000  0000000000000000           0     0     1
  [ 8] .eh_frame         PROGBITS         0000000000000000  000000e0
       0000000000000058  0000000000000000   A       0     0     8
  [ 9] .rela.eh_frame    RELA             0000000000000000  000003c8
       0000000000000030  0000000000000018   I      11     8     8
  [10] .shstrtab         STRTAB           0000000000000000  000003f8
       0000000000000061  0000000000000000           0     0     1
  [11] .symtab           SYMTAB           0000000000000000  00000138
       0000000000000198  0000000000000018          12    12     8
  [12] .strtab           STRTAB           0000000000000000  000002d0
       0000000000000079  0000000000000000           0     0     1
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)
readelf -S simple_section.o -S --section-headers

There is a section called Relocation Table. 

nm - list symbols from object files.

moonx@moonx:chapter3$ nm simple_section.o 
0000000000000000 T func1
0000000000000000 D global_init_var
0000000000000000 b global_static_var
0000000000000004 C global_uninit_var
0000000000000022 T main
                 U printf
0000000000000004 d static_var.1842
0000000000000004 b static_var2.1843
nm simple_section.o   nm - list symbols from object files

moonx@moonx:chapter3$ c++filt _ZN1N1C4funcEi
N::C::func(int)

chapter 4  static link

chapter 6 load and process

chapter 7 dynamic link

chapter 8 orgnize of linux share libs

chapter 10 memory

chapter 11 CRT libs

chapter 12 system call and API

chapter 13 realize of CRT libs

原文地址:https://www.cnblogs.com/cjyp/p/11328588.html