[PATCH] allow empty string as argument to -Map

Rasmus Villemoes rv@rasmusvillemoes.dk
Fri Oct 23 12:31:26 GMT 2020


On 28/05/2020 11.54, Nick Clifton wrote:
> Hi Rasmus,
> 
>> That makes a lot of sense, thanks. And one can get "my" behaviour by
>> passing "-Map=." or "-Map .", 
> 
> Ha!  I had not even though of that.
> 
>> ... eliminates the somewhat clumsy need to specify the empty string as
>> argument, 
> 
> Agreed.

Sorry for resurrecting this, and not thinking of this sooner, but it
just occurred to me that passing -Map=. only works automatically if the
-o argument is a relative path. If the -o argument is absolute, that
will lead to trying to create a map file at, say,
".//home/ravi/some/project/foo.so.out", which won't work given that the
working directory is very likely already "/home/ravi/some/project". One
could pass -Map=/, but that would then break in the other direction when
the -o argument is relative.

Since the main point of this is to be able to just do "LDFLAGS +=
<something>" to always get a linker map for each output artifact,
without hooking into each individual project's build system and figuring
out how to add that flag to each build target, can we special-case . to
always mean "generate a map file next to the output file", i.e. in that
case check whether output_filename starts with '/' and if so do not
prepend "./" (but still append ".map", of course)? Or is there some
better way?

Rasmus


More information about the Binutils mailing list