[PATCH] allow empty string as argument to -Map
Rasmus Villemoes
rv@rasmusvillemoes.dk
Tue May 26 07:01:40 GMT 2020
More information about the Binutils mailing list
Tue May 26 07:01:40 GMT 2020
- Previous message (by thread): [PATCH] gas: Silence GCC 10 warning on tc-mcore.c
- Next message (by thread): [PATCH] allow empty string as argument to -Map
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In meta-build systems like Yocto, it's rather easy to add flags like -fdata-sections, -ffunction-sections, -Wl,--gc-sections to global CFLAGS/LDFLAGS. But when digging into what effect those had on the build of a particular package, it would be nice to also have a map file automatically generated. That's currently a bit harder, since it requires patching the build system of each individual package to add something like -Wl,-Map=$@.map somewhere. My first instinct was to make the argument to -Map optional, but that will of course break anybody that uses the form "-Map foo.map" rather than "-Map=foo.map". So, as the next best thing, use a previously bogus value (the empty string) as a sentinel to indicate "use the output filename + .map". Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk> --- ld/ld.texi | 4 +++- ld/lexsup.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ld/ld.texi b/ld/ld.texi index 9f562935be..25ce1d6524 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1759,7 +1759,9 @@ Print a summary of all target-specific options on the standard output and exit. @kindex -Map=@var{mapfile} @item -Map=@var{mapfile} Print a link map to the file @var{mapfile}. See the description of the -@option{-M} option, above. +@option{-M} option, above. Specifying the empty string as @var{mapfile} +(that is, @code{-Map=}) causes the link map to be written to a file +named after the @var{output} file, with @code{.map} appended. @cindex memory usage @kindex --no-keep-memory diff --git a/ld/lexsup.c b/ld/lexsup.c index 2597e2d630..e7ab07b50f 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -1617,6 +1617,11 @@ parse_args (unsigned argc, char **argv) } } + if (config.map_filename && !config.map_filename[0]) { + if (asprintf (&config.map_filename, "%s.map", output_filename) < 0) + einfo (_("%F%P: %s: can not create name of map file: %E\n")); + } + if (command_line.soname && command_line.soname[0] == '\0') { einfo (_("%P: SONAME must not be empty string; ignored\n")); -- 2.23.0
- Previous message (by thread): [PATCH] gas: Silence GCC 10 warning on tc-mcore.c
- Next message (by thread): [PATCH] allow empty string as argument to -Map
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list