How to remove STRTAB and SYMTAB sections from ELF using Codewarrior options.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to remove STRTAB and SYMTAB sections from ELF using Codewarrior options.

1,380 次查看
Luke_K
Contributor II

Hi,

I would like to remove Debug Section (including STRTAB and SYMTAB) in ELF using Codewarrior compile options.

I set to Off for "Generate DWARF Information".

But, ELF still has STRTAB and SYMTAB sections.

Please let me know how to remove STRTAB and SYNTAB from ELF.

Can I use strip ccmd? If possible, let me know how to use it.

 

Codewarrior Version : Version 11.0

 

Thanks.

0 项奖励
回复
3 回复数

1,308 次查看
Luke_K
Contributor II

Hello, Stanish

 

Thanks for your kind reply.

I have a commercial program that removes .strtab and .symtab sections from elf files.

I think the program is similar to the strip program you recommended.

What I would like to know about this topic is if there is an option in the CodeWarrior preferences menu.

I'm trying to download the program (S32DS).

(There are some problems to download the program.. so I need to have some time.)

 

I will let you know the test results.

 

Thanks.

0 项奖励
回复

1,200 次查看
stanish
NXP Employee
NXP Employee
I'm not aware of any option in CodeWarrior preferences menu that would strip or avoid creation of SYMTAB and STRTAB sections. Other approach could be just to create separate elf derived from original one, that contains just code sections. But again there is no native support for this in CodeWarrior and you will probably have to use "external" tools.
0 项奖励
回复

1,318 次查看
stanish
NXP Employee
NXP Employee

Hi Luke,

Thanks for your question. You can indeed control the Off for "Generate DWARF Information" but it leaves string and symbol table in place.

I'd suggest you to install S32DS for Power v2.1:

https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/S32-Design-Studio-for-Power-Architect...

It contains set of binutils:

"C:\NXP\S32DS_Power_v2.1\S32DS\build_tools\powerpc-eabivle-4_9\bin"

 

And you can try to use strip utility with parameter -s:

C:\NXP\S32DS_Power_v2.1\S32DS\build_tools\powerpc-eabivle-4_9\bin>powerpc-eabivle-strip
Usage: powerpc-eabivle-strip <option(s)> in-file(s)
Removes symbols and sections from files
The options are:
-I --input-target=<bfdname> Assume input file is in format <bfdname>
-O --output-target=<bfdname> Create an output file in format <bfdname>
-F --target=<bfdname> Set both input and output format to <bfdname>
-p --preserve-dates Copy modified/access timestamps to the output
-D --enable-deterministic-archives
Produce deterministic output when stripping archives
-U --disable-deterministic-archives
Disable -D behavior (default)
-R --remove-section=<name> Also remove section <name> from the output
--remove-relocations <name> Remove relocations from section <name>
-s --strip-all Remove all symbol and relocation information
-g -S -d --strip-debug Remove all debugging symbols & sections
--strip-dwo Remove all DWO sections
--strip-unneeded Remove all symbols not needed by relocations
--only-keep-debug Strip everything but the debug information

 I tried to precess CodeWarrior generated elf for MPC56xx and it seems the sections are not present any more but I lost the ability to dissasemble the resulted elf. 

Could you try on your side if the final elf is still usable(loadable) for you? if not please consider to distribute a binary file e.g. s-record instead if .elf

This step yould be easily automated by adding strip into postbuild steps:

stanish_0-1736773921521.png

 

hope it helps.

Stan

 

0 项奖励
回复