如何从.map文件中获取目标文件名

时间:2016-08-12 10:20:16

标签: scripting grep pattern-matching

我需要从.map文件中收集目标文件的所有名称,列出它们,然后计算它们在不同内存区域中占用的空间。地图文件很大(<2500行)并且手动操作需要花费很多时间。 我试过了

           grep -r '.o' *.map

但它给了我很多结果,其中包含了&#39; o。 这是来自地图文件的示例

AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(start.o)
                              (start)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-main.lib(contiki-main.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(start.o) (main)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-main.lib(contiki-main.o) (ss_dhanush_services_init)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(mio_dma_drv.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init) (MIO_Dma_Init)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(dma_drv.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init) (Dma_Init)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(memory_map.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(mio_dma_drv.o) (Virtual_To_Physical)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(socVer.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init) (System_SOC_VersionInit)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(c_fuction.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init) (memset)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(Rip_api.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(ss_dhanush_init) (ripStartService)
AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(irq_handler.o)
                              AProject/I3/S-SDK/MPU_Asymmetri_ported_Lib_changes_trunk_code/AON/output/contiki-dhanushss.a(mio_dma_drv.o) (register_isr)

我只需要列出此地图文件中的目标文件列表。

1 个答案:

答案 0 :(得分:0)

我不知道你是什么意思list of object files,但试试这行:

 grep -r -Po '[^(]*[.]o(?=[)])' *.map

结果是:

start.o
contiki-main.o
start.o
contiki-main.o
mio_dma_drv.o
dma_drv.o
memory_map.o
mio_dma_drv.o
socVer.o
c_fuction.o
Rip_api.o
irq_handler.o
mio_dma_drv.o