[gofrontend-dev] Re: Go patch committed: Don't strip Go programs

Lynn A. Boger laboger@linux.vnet.ibm.com
Mon Mar 2 19:52:00 GMT 2015


On 02/27/2015 02:46 PM, Ian Lance Taylor wrote:
> On Fri, Feb 27, 2015 at 12:07 PM, Matthias Klose <doko@ubuntu.com> wrote:
>> is there anything which could be stripped without scarifying functionality?
>> Linux distributions usually strip things by default, so a hint what exactly is
>> needed to keep the functionality would be appreciated.

I'm not familiar with what sections are being stripped when you say 
"Linux distributions usually strip things by default".  Do you mean only 
the debug sections are usually stripped?
> What is needed is file/line information.  However, I don't know of an
> option to strip that discards most debug info but keeps file/line
> info.  The gold linker can do it (--strip-debug-non-line) but that
> obviously would have to be used when building the library; it doesn't
> help at install time.

I played around with the strip command and from what I can tell it 
doesn't have the right set of options to allow you to remove only debug 
sections and leave other sections intact.  However it looks like you can 
use objcopy to remove specific sections.  The minimum sections I was 
able to remove and get it to work were these.  I first tried with just 
debug_line, and that didn't produce the line numbers; if I added 
debug_info then various errors occurred until I also included 
debug_abbrev, debug_ranges, debug_str.

objcopy -R .debug_aranges -R .debug_frame -R .debug_loc libgo.so.7.0.0

- Lynn
> Ian
>
>
>



More information about the Gcc-patches mailing list