Download Embedded Linux Primer: A Practical, Real-World

Transcript
[28].debug_pubnamesPROGBITS0000000001e8c8001aae00001
[29].debug_infoPROGBITS00000000020376013d2700001
[30].debug_abbrevPROGBITS0000000003409d002ede00001
[31].debug_linePROGBITS00000000036f7b0034a200001
[32].debug_framePROGBITS0000000003a42000338000004
[33].debug_strPROGBITS0000000003d7a000067900001
[34].note.gnu.arm.ideNOTE0000000003de1900001c00001
[35].debug_rangesPROGBITS0000000003de3500001800001
[36].shstrtabSTRTAB0000000003de4d00018300001
[37].symtabSYMTAB0000000003e5e8004bd010387734
[38].strtabSTRTAB000000000431b80021bf00001
KeytoFlags:
W(write),A(alloc),X(execute),M(merge),S(strings)
I(info),L(linkorder),G(group),x(unknown)
O(extraOSprocessingrequired)o(OSspecific),p(processorspecific)
$
YoucanseefromListing15-1thattherearemanysectionscontainingdebuginformation.Thereis
alsoa.commentsectionthatcontainsmorethan2KB(0x940)ofinformationthatisnotnecessaryfor
theapplicationtofunction.Thesizeofthisexamplefile,includingdebuginformation,ismorethan
275KB.
$ls-lwebsdemo
-rwxrwxr-x1chrischris283511Nov818:48websdemo
Ifwestripthisfileusingthestriputility,wecanminimizeitssizetopreserveresourcesonour
targetsystem.Listing15-2showstheresults.
Listing15-2.StripTargetApplication
$xscale_be-strip-s-R.comment-owebsdemo-strippedwebsdemo
$ls-lwebsdemo*
-rwxrwxr-x1chrischris283491Apr909:19websdemo
-rwxrwxr-x1chrischris123156Apr909:21websdemo-stripped
$
Herewestripboththesymbolicdebuginformationandthe.commentsectionfromtheexecutable
file.Wespecifythenameofthestrippedbinaryusingthe-ocommandlineswitch.Youcanseethat
the resulting size of the stripped binary is less than half of its original size. Of course, for larger
applications,thisspacesavingscanbeevenmoresignificant.ArecentLinuxkernelcompiledwith
debuginformationwaslargerthan18MB.AfterstrippingasinListing15-2,theresultingbinarywas
slightlylargerthan2MB!
Fordebugginginthisfashion,youplacethestrippedversionofthebinaryonyourtargetsystem
andkeepalocalunstrippedcopyonyourdevelopmentworkstationcontainingsymbolicinformation
neededfordebugging.Youusegdbserveronyourtargetboardtoprovideaninterfacebacktoyour
developmenthostwhereyourunthefull-blownversionofGDBonyournonstrippedbinary.