Operating System - HP-UX
1832978 Members
3179 Online
110048 Solutions
New Discussion

How to compile a binary to be stripped

 
yangk
Frequent Advisor

How to compile a binary to be stripped

Hi All,

I want to build a binary with stripped,and
the cflag and ldflag is like this:

CC=cc
CFLAGS=-Ae +w1 +O1 +DAportable +ESlit -DHPUX11
LDFLAGS=-Wl,+nodefaultrpath

But it seems the bianry built with this flags
is not stripped,

root# file `pwd`/a.out
a.out: PA-RISC1.1 shared executable dynamically linked -not stripped

So how can i build the binary to be stripped?

Thanks in advance!

Kevin


4 REPLIES 4
Laurent Menase
Honored Contributor

Re: How to compile a binary to be stripped

add -Wl,-s or -s in LDFLAGS

LDFLAGS=-Wl,+nodefaultrpath -s
or
LDFLAGS=-Wl,+nodefaultrpath -Wl,-s
James R. Ferguson
Acclaimed Contributor

Re: How to compile a binary to be stripped

Hi Kevein:

I suppose it goes without saying, but after the fact, 'strip(1)' performs the same action on the binary as 'ld -s'.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: How to compile a binary to be stripped

>+DAportable

If you don't care about old PA1.1 systems, you can replace this by +DA2.0.

I don't see any "-s" option.

>Laurent: add -Wl,-s or -s in LDFLAGS

There is no need for -Wl, since -s is a full fledged driver option.

>JRF: I suppose it goes without saying, but after the fact, strip(1) performs the same action on the binary as "ld -s".

No, it doesn't, there are slight differences but not enough for ordinary mortals to care. :-)
But using strip(1) gives you more choices. I.e. you can keep the original around.
yangk
Frequent Advisor

Re: How to compile a binary to be stripped

Hi All,

Got it! Thanks!