aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-05-28 10:51:29 +0100
committerNick Clifton <nickc@redhat.com>2020-05-28 10:51:29 +0100
commit72a3b182e1352a2e83d8fb781b848dba9c4be6c5 (patch)
treea62ef6cadac6c1e3b5811546265af34fa3ad93af /ld
parent1c912705af057b0d30ea51af46d8a00014a84034 (diff)
downloadbinutils-72a3b182e1352a2e83d8fb781b848dba9c4be6c5.zip
binutils-72a3b182e1352a2e83d8fb781b848dba9c4be6c5.tar.gz
binutils-72a3b182e1352a2e83d8fb781b848dba9c4be6c5.tar.bz2
Linker: Remove support for -Map= with an empty argument.
* lexsup.c (parse_args): Generate an error if a name is not provided to the -Map option. (ld_options): Mention that the -Map option supports a directory name as an argument. * NEWS: Remove mention of support for an empty string as an argument to -Map. * ld.texi: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/NEWS5
-rw-r--r--ld/ld.texi10
-rw-r--r--ld/lexsup.c22
4 files changed, 29 insertions, 18 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b84b05b..580f147 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2020-05-28 Nick Clifton <nickc@redhat.com>
+
+ * lexsup.c (parse_args): Generate an error if a name is not
+ provided to the -Map option.
+ (ld_options): Mention that the -Map option supports a directory
+ name as an argument.
+ * NEWS: Remove mention of support for an empty string as an
+ argument to -Map.
+ * ld.texi: Likewise.
+
2020-05-27 Hans-Peter Nilsson <hp@axis.com>
PR ld/22909
diff --git a/ld/NEWS b/ld/NEWS
index 98f07a7..2240aeb 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,9 +1,8 @@
-*- text -*-
* The -Map=<filename> command line option has been extended so that if
- <filename> is omitted then a file called <output-filename>.map will be
- created. Plus if <filename> is a directory then
- <filename>/<output-filename>.map will be created.
+ <filename> is a directory then <filename>/<output-filename>.map will be
+ created.
* Add a command-line option for ELF linker, --warn-textrel, to warn that
DT_TEXTREL is set in a position-independent executable or shared object.
diff --git a/ld/ld.texi b/ld/ld.texi
index 5234252..cb38f47 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1760,12 +1760,10 @@ 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. 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.
-Specifying a directory as @var{mapfile} causes the link map to be
-written into a file inside the directory. The name of the file is
-again based upon the @var{output} filename with @code{.map} appended.
+@option{-M} option, above. Specifying a directory as @var{mapfile}
+causes the linker map to be written into a file inside the directory.
+The name of the file is based upon the @var{output} filename with
+@code{.map} appended.
@cindex memory usage
@kindex --no-keep-memory
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 49c4f23..781f58a 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -359,7 +359,7 @@ static const struct ld_option ld_options[] =
{ {"init", required_argument, NULL, OPTION_INIT},
'\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
{ {"Map", required_argument, NULL, OPTION_MAP},
- '\0', N_("[FILE]"), N_("Write a map file (default: <outputname>.map)"), ONE_DASH },
+ '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
{ {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
'\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
{ {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
@@ -1598,29 +1598,33 @@ parse_args (unsigned argc, char **argv)
/* Run a couple of checks on the map filename. */
if (config.map_filename)
{
- /* If name has been provided then use the
- output filename with a .map extension. */
if (config.map_filename[0] == 0)
{
- /* FIXME: This is a memory leak as the string is never freed. */
- if (asprintf (&config.map_filename, "%s.map", output_filename) < 0)
- einfo (_("%F%P: %s: can not create name of map file: %E\n"));
+ einfo (_("%P: no file/directory name provided for map output; ignored\n"));
+ config.map_filename = NULL;
}
else
{
struct stat s;
/* If the map filename is actually a directory then create
- a file inside it, again based upon the output filename. */
+ a file inside it, based upon the output filename. */
if (stat (config.map_filename, &s) >= 0
&& S_ISDIR (s.st_mode))
{
char * new_name;
- /* FIXME: Another memory leak. */
+ /* FIXME: This is a (trivial) memory leak. */
if (asprintf (&new_name, "%s/%s.map",
config.map_filename, output_filename) < 0)
- einfo (_("%F%P: %s: can not create name of map file: %E\n"));
+ {
+ /* If this alloc fails then something is probably very
+ wrong. Better to halt now rather than continue on
+ into more problems. */
+ einfo (_("%P%F: cannot create name for linker map file: %E\n"));
+ new_name = NULL;
+ }
+
config.map_filename = new_name;
}
}