From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 51A473870843 for ; Thu, 28 May 2020 09:54:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 51A473870843 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-XerY1K1nMWqXcjJqvUaB3g-1; Thu, 28 May 2020 05:54:31 -0400 X-MC-Unique: XerY1K1nMWqXcjJqvUaB3g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6D25800D24; Thu, 28 May 2020 09:54:30 +0000 (UTC) Received: from [10.36.114.54] (ovpn-114-54.ams2.redhat.com [10.36.114.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C030AA09B9; Thu, 28 May 2020 09:54:29 +0000 (UTC) Subject: Re: [PATCH] allow empty string as argument to -Map To: Rasmus Villemoes , binutils@sourceware.org References: <20200526070140.25380-1-rv@rasmusvillemoes.dk> <01faf722-46fc-e0a6-6a58-2490e07937d6@redhat.com> <7ad73b09-c551-9a17-f0fa-0839919158b4@rasmusvillemoes.dk> From: Nick Clifton Autocrypt: addr=nickc@redhat.com; prefer-encrypt=mutual; keydata= mQINBFm/2cUBEADkvRqMWfAryJ52T4J/640Av5cam9ojdFih9MjcX7QWFxIzJfTFYq2z+nb4 omdfZosdCJL2zGcn6C0AxpHNvxR9HMDkEyFHKrjDh4xWU+pH4z9azQEqJh331X7UzbZldqQo 16VkuVavgsTJaHcXm+nGIBTcUbl2oiTtHhmuaYxx6JTMcFjC7vyO5mLBw78wt52HBYweJ0Nj HBvvH/JxbAAULSPRUC61K0exlO49VFbFETQ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IwzMketvVC/cbbKDZqf0uTDy3jP65OFhSkTEIy nYv1Mb4JJl3Sq+haUbfWLAV5nboSuHmiZE6Bz2+TjdoVkNwHBfpqxu6MlWka+P98SUcmY8iV hPy9QC1XFOGdFDFf1kYgHW27mFwds35NQhNARgftAVz9FZXruW6tFIIfisjr3rVjD9R8VgL7 l5vMr9ylOFpepnI6+wd2X1566HW7F1Zw1DIrY2NHL7kL5635bHrJY4n7o/n7Elk/Ca/MAqzd IZxz6orfXeImsqZ6ODn4Y47PToS3Tr3bMNN9N6tmOPQZkJGHDBExbhAi/Jp8fpWxMmpVCUl6 c85cOBCR4s8tZsvGYOjR3CvqKrX4bb8GElrhOvAJa6DdmZXc7AyoVMaTvhpq3gJYKmC64oqt 7zwIHwaCxTbP6C6oUp9ENRV7nHnXN3BlvIgCo4QEs6HkDzkmgYlCEOKBiDyVMSkPDZdsspa+ K4GlU2Swi/BDJMjtDxyo+K0M81LXXxOeRfEIfPtZ3ddxBKPva1uSsuz+pbN9d1JY8Ko5T/h1 6susi2ReUyNJEJaSnjO5z13TQ1U= Organization: Red Hat Message-ID: <0fc094c4-c915-511c-c5da-2654811fbeec@redhat.com> Date: Thu, 28 May 2020 10:54:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <7ad73b09-c551-9a17-f0fa-0839919158b4@rasmusvillemoes.dk> Content-Language: en-GB X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------EBBF539BC94180EFFBE748FB" X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2020 09:54:35 -0000 This is a multi-part message in MIME format. --------------EBBF539BC94180EFFBE748FB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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. > So before this gets set in stone, can I retract my suggestion of > assigning meaning to the empty string (maybe continue to handle it > internally equivalent to ".", but not advertising it)? I have made the change. See the attached patch. I decided that for the empty string case it would be best to generate a message telling the user and ignoring the map file request. > (And perhaps change "map file" to "link map" or "linker map") Also done. Cheers Nick ld/ChangeLog 2020-05-28 Nick Clifton * 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. --------------EBBF539BC94180EFFBE748FB Content-Type: text/x-patch; charset=UTF-8; name="map.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="map.patch" diff --git a/ld/NEWS b/ld/NEWS index 98f07a73e1..2240aeb788 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,9 +1,8 @@ -*- text -*- * The -Map= command line option has been extended so that if - is omitted then a file called .map will be - created. Plus if is a directory then - /.map will be created. + is a directory then /.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 52342523ed..cb38f47cd3 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 49c4f23950..781f58aff7 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: .map)"), ONE_DASH }, + '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/.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; } } --------------EBBF539BC94180EFFBE748FB--