From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 65D1E3857C52 for ; Thu, 30 Sep 2021 11:56:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65D1E3857C52 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-11-7l6T1dizPt6qdRE20PcSjg-1; Thu, 30 Sep 2021 07:56:12 -0400 X-MC-Unique: 7l6T1dizPt6qdRE20PcSjg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C28C68145F5 for ; Thu, 30 Sep 2021 11:56:11 +0000 (UTC) Received: from comet.redhat.com (unknown [10.39.194.190]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A5931025E9F for ; Thu, 30 Sep 2021 11:56:11 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: objcopy: Fail if attempting to redefine symbols in LTO files Date: Thu, 30 Sep 2021 12:56:09 +0100 Message-ID: <878rzep99i.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 30 Sep 2021 11:56:15 -0000 Hi Guys, I am applying the patch below to add a fatal error message to objcopy if the user attempts to use --redefine-sym (or --redefine-syms) on an object file containing LTO information. Since LTO uses its own symbol tables, plus modifying symbols in the ordinary symbol table, symbol redefinition is not going to work. (Plus I did not fancy trying to implement the code to make it work. Especially since the LTO symbol table format is not fixed or even well defined). Cheers Nick binutils/ChangeLog 2021-09-30 Nick Clifton * objcopy.c (filter_symbols): Fail if attempting to dredefine symbols in an LTO object file. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index fd7557fe433..75fd89d338b 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1542,6 +1542,13 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, { char *new_name; + if (name[0] == '_' + && name[1] == '_' + && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0) + { + fatal (_("redefining symbols does not work on LTO-compiled object files")); + } + new_name = (char *) lookup_sym_redefinition (name); if (new_name == name && (flags & BSF_SECTION_SYM) != 0)