From patchwork Fri Mar 13 02:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 38538 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id D69963AA7CB1 for ; Fri, 13 Mar 2020 02:09:59 +0000 (GMT) Received: by mail-pf1-x443.google.com with SMTP id b72so4233176pfb.11 for ; Thu, 12 Mar 2020 19:09:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=09PovV3ByTGbGApjhl8mJEQ/hZxF1BIHiuIDGzrcub8=; b=Wqg3S+siS3UwGdeUVwwAN+QiJfbIcCksqaimgKRW8WMbuXNxJyrE1K9f6gKaWdSvAs cACDRsanweeqRgBFzlyyqvNRekxayVkJdOuLTUmA0Omf1SG+MDmxtLR68QCgS0cFFrpD jMyGJLroP/YoiWW9T3ROSVX9vPqOWVB0RMZ6a1EQORX313BUpvchoRFRj3yDRr1BOTiu h5qDxwr4kGxDbKSYYAChd+9UtFN3TzS+nwaAN0pRDAiawSKDZ7E/SkvUnyOX+XY3oaac 8jriOgPXDcM29AoFdG1r2eZWajjJw21TnKeiyrnGKt2zO3meP0IF17IyafASl9OQGBI+ 9i2g== X-Gm-Message-State: ANhLgQ2u8NuAPnCnkFse5Ow79BBwoiZsYNjCQy9NIXOf5yxV7Va1X0bb rkkBpjVx03n+RWn50gm48iKV8+9MocqdYA== X-Google-Smtp-Source: ADFU+vvkqPu3FYsxcfQ+b7aZdbL2v4ilXENKjl3P0RU3N1novQRyBQ2B2l3IGGdgVMB5KVeUuPv63A== X-Received: by 2002:a63:4755:: with SMTP id w21mr9523930pgk.302.1584065398402; Thu, 12 Mar 2020 19:09:58 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id k189sm9279440pgc.24.2020.03.12.19.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 19:09:57 -0700 (PDT) Date: Thu, 12 Mar 2020 19:09:55 -0700 From: Fangrui Song To: libc-alpha@sourceware.org Subject: [PATCH] elf: Support lld-style link map for librtld.map Message-ID: <20200313020955.rcx63wkdsi6bodd4@google.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-40.9 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, FSL_HELO_FAKE, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 02:10:00 -0000 GNU ld and gold's -Map include a line like: path/to/build/libc_pic.a(check_fds.os) lld -Map does not have the archive member list, but we can still derive the members from the following output VMA LMA Size Align Out In Symbol ... 1a1c0 1a1c0 e2 16 path/to/build/libc_pic.a(check_fds.os):(.text) --- elf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elf/Makefile b/elf/Makefile index da689a2c7b..b035407112 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -512,9 +512,10 @@ $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a rm -f $@.o mv -f $@T $@ +# For lld, skip preceding addresses and values before matching the archive and the member. $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile LC_ALL=C \ - sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \ + sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \ $< | \ while read lib file; do \ case $$lib in \