jalooc
jalooc

Reputation: 1227

GNU linker wildcard for -wrap option

Is there a way of using the -wrap option for all functions defined in a source file, without listing them by hand?

I thought about some wildcard for that option, but my research resulted in nothing. I also considered investigating a way for extraction of source file functions with make, also without success.

Is there any other way to do it?

Upvotes: 1

Views: 272

Answers (1)

Jean-Baptiste Yunès
Jean-Baptiste Yunès

Reputation: 36431

You may use ctags as suggested here, sed to add -wrap in front of each and inject the result on the command line.

--- Edit ---

For example, something like:

a=`ctags -o- --fields=-fkst --c-kinds=f myprint.c | cut -f1 | sed -e 's/^\(.*\)/-wrap \1/g'`
echo $a

would give you:

-wrap main -wrap myprint

You can also combine everything in one line:

ld ... `ctags -o- --fields=-fkst --c-kinds=f myprint.c | cut -f1 | sed -e 's/^/-wrap /'`

Upvotes: 1

Related Questions