[PATCH] allow empty string as argument to -Map

Nick Clifton nickc@redhat.com
Fri Oct 30 16:35:04 GMT 2020


Hi Rasmus,

>> My feeling is that we ought to extract the basename of any output file
>> and use that, and always honour the directory name specified in the -Map
>> option. 

> However, the problem with using (only) the basename of the -o argument
> is that the build (not the single ld invocation, but the surrounding
> build system) could produce several binaries of the same name in
> different directories, so we (a) would clobber the .map files and (b)
> cannot tell which binary the single surviving .map belongs to.

That does not sound likely to me.  In order for a clobber to occur
the user would have to build multiple binaries with the same output
name and using the same map directory.  But in order for the output
binaries not to clobber each other they would have to be built into
different output directories.  ie:

  -o foo/bar -Map=/mapdir
  -o baz/bar -Map=/mapdir

It seems to me that this is only likely to occur when creating multiple
versions of the same binary (eg with different ABI options) and the map
dir is being automatically added to the build.  (If the user added the
-Map option then they would almost certainly include the discriminating 
directory name as well).


> -Map=AUTO

Hmm. maybe.

Another possibility is to have the linker not overwrite an existing
map file, but instead append a timestamp/random number instead.  So

  -o foo -Map=.

would create ./foo.map if it does not exist, or .foo.202010301630.map
if foo.map exists.  As distinguishing between these map files, I would
assume that looking at their contents, and seeing the input files mentioned
should be enough.


> -Map argument is given, but the env variable LDAUTOMAP is set,

I am strongly against environment variables, if they can be avoided.
I know that they linker does use some, but I consider this to be a
mistake.  The bug problem with environment variables is that they make
generating bug reports really hard.  Most users never include
environment variables in their reports, and often they do not even
know that they are there.

Cheers
  Nick



More information about the Binutils mailing list