目标文件.o

0 简介

目标文件就是源代码编译之后但是未进行链接的那些中间文件,.o或者.obj,由于它和可执行文件的内容与结构相似,所以一般跟可执行文件格式一起采用一种格式存储。
ELF (executable linkable format)
在这里插入图片描述
在这里插入图片描述
objdump工具查看.o文件
https://blog.csdn.net/q2519008/article/details/82349869

objdump -h hello.o

hello.o:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         0000001c  0000000000000000  0000000000000000  00000040  2**0
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000000  0000000000000000  0000000000000000  0000005c  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  0000000000000000  0000000000000000  0000005c  2**0
                  ALLOC
  3 .rodata       0000000f  0000000000000000  0000000000000000  0000005c  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .comment      0000002a  0000000000000000  0000000000000000  0000006b  2**0
                  CONTENTS, READONLY
  5 .note.GNU-stack 00000000  0000000000000000  0000000000000000  00000095  2**0
                  CONTENTS, READONLY
  6 .eh_frame     00000038  0000000000000000  0000000000000000  00000098  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA

objdump -s hello.o

Contents of section .text:
 0000 554889e5 488d3d00 000000b8 00000000  UH..H.=.........
 0010 e8000000 00b80000 00005dc3           ..........].    
Contents of section .rodata:
 0000 68656c6c 6f20776f 726c6421 212100    hello world!!!. 
Contents of section .comment:
 0000 00474343 3a202855 62756e74 7520372e  .GCC: (Ubuntu 7.
 0010 352e302d 33756275 6e747531 7e31382e  5.0-3ubuntu1~18.
 0020 30342920 372e352e 3000               04) 7.5.0.      
Contents of section .eh_frame:
 0000 14000000 00000000 017a5200 01781001  .........zR..x..
 0010 1b0c0708 90010000 1c000000 1c000000  ................
 0020 00000000 1c000000 00410e10 8602430d  .........A....C.
 0030 06570c07 08000000                    .W...... 

.bss .text .data区别
https://www.cnblogs.com/yanghong-hnu/p/4705755.html

2 elf文件结构

在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值