From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by sourceware.org (Postfix) with ESMTPS id 8730C3851C3A for ; Tue, 26 May 2020 07:01:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8730C3851C3A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rv@rasmusvillemoes.dk Received: by mail-ed1-x544.google.com with SMTP id c35so411422edf.5 for ; Tue, 26 May 2020 00:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bC2oPLQ8ESfQWoxJhy9xckbeqxUC7h0AoSbWVMHbumU=; b=MGpN6Vg5iuOHATtC2qX14kr62IvU217NaQ1sDpI2MIe9cBga6hf43hr5aDeKcQZxHP lBSA5aNMbWyYhl5iy5mBCUMsYH8ZigE2acG/1/gOzSoLi5i/FAnLByUsxELVFW8JexDQ KMs+T0GO3oQoBvD6/xVWCK8dPWLrHFUG9ZL9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bC2oPLQ8ESfQWoxJhy9xckbeqxUC7h0AoSbWVMHbumU=; b=bS/LZ/44G3vsph24eMvEaUCjkUnJKnYuvP+5J2tvHuBH9x0YqaFCltyAhBnyGU6fy4 zm+I0rc17KF7t9bQvwQ5L7tymIUzXbl6G4ggNr4nFsozQZ8yPtp2sNtH15pCvFqTtr7B /FVzav4ps5Ok6CnlL50raO1orFszkhMdwSP9Nsc+QPaF7+RMaQUyzMR9581TSmN5ZmY8 eV1pBEn1V0XkbbtfFcv8657hSVJEQktFHnzYOrpQ6547gtB3lcVJV1CtWbyly1HsebTR MzyFLIlR3SJX9dD1M5Hb9fEJaZp1ugb8seARn/EyIqc9VPJwVutzhFbDxPq48wVWKQl2 lkgQ== X-Gm-Message-State: AOAM532ln1hqnNFv1OAzmSfLnRadWxMkqDT69dv1h+Gghy5e0d9cvWIk RPmzc/Ome3yX3Exm/mRc45H96JuLKH0= X-Google-Smtp-Source: ABdhPJy7HuUl4sOCs8/bx9Lo1BbPOdipH0HWWE/8TEqXeA9JmSiPghAw3wdUxyWmcX6jDi8wkA9T2g== X-Received: by 2002:a05:6402:30b4:: with SMTP id df20mr18520639edb.158.1590476505355; Tue, 26 May 2020 00:01:45 -0700 (PDT) Received: from prevas-ravi.prevas.se (ip-5-186-116-45.cgn.fibianet.dk. [5.186.116.45]) by smtp.gmail.com with ESMTPSA id n16sm17128604ejo.123.2020.05.26.00.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 00:01:44 -0700 (PDT) From: Rasmus Villemoes To: binutils@sourceware.org Cc: Rasmus Villemoes Subject: [PATCH] allow empty string as argument to -Map Date: Tue, 26 May 2020 09:01:40 +0200 Message-Id: <20200526070140.25380-1-rv@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Tue, 26 May 2020 07:01:48 -0000 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 --- 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