From patchwork Fri Oct 4 08:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 98360 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02DCC384514B for ; Fri, 4 Oct 2024 08:26:34 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 6DF76385DDEC for ; Fri, 4 Oct 2024 08:24:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DF76385DDEC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6DF76385DDEC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1032 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728030284; cv=none; b=JBM/GOX7jGBSa83+WWoPLhnVJQQW8AfTFvho1iOYRgTy2v8ijbiKXl848Od3i4jloBbqI1oPQ5NHXuxLBk9Cj9+1nGysxglFeNMy6YqF9dkix1nd8rw3Y3NySzjs2oK0Y/PCa9cOh4kur5FtDgp3UFXBBfyir2Tf9MHxAvFDpao= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728030284; c=relaxed/simple; bh=DEMWDN9iYcp5JwUhgM6VOr9O2ivbEQPX3MC3JlyXUIU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=MClkRf8uE7ng8kV1c7F7y2xVbdiecAlvpne0RiCpz1+RlEpnD01zO1D0luIVbRC/jri2e2EWPDgTQy3cjJZ3a57vRFkTVtcK2Phr6s/ODzS9nAJSNh7A/+/rXPo1juODN+mHJHSinakRyFeU1jX2sgVvKHRpHV1EnnLYr1gehpk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2e077a4b8c0so1347055a91.1 for ; Fri, 04 Oct 2024 01:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728030281; x=1728635081; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0AbC+xZe/qxAqv1ayQfjhtQP03ku9OM22UKMnFdJ5l4=; b=AUpkgYSWrEFYn71+SHOJmkueMRTIfuackZYNFxpCwxsiQ/y9EDAH27e3iZFrEWiQiH L6nlLi0EuqhIJ44yYPMbT3A16eg/ygJ5I7QKXhEz9hF+umw43Yi6fVY34Fsw1DHI7YR6 KwZDKUY19AQvdlthbYCCzN25IGPz2tDdEyB7an6LxrZpCcwzHD1miw6+/sT5PuQUON8n OZIR4TlbEvWCMoQ0ZDxGzOnSHsANoujTBFrorGNoqCXsEgAD/8yePkCKt9TKPpRiI9QP LkjzVog8UsHyUGd2LOkqCnw1THfBnvH9D3MB6EnUXV1CFWwKg/yQ4FqIgKTcK7N1CT/S BBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728030281; x=1728635081; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0AbC+xZe/qxAqv1ayQfjhtQP03ku9OM22UKMnFdJ5l4=; b=JrysA5RTj9vlGmH+KZw0Tgtg4FdLUHh2gfNo+RIg3T+5Gdaxgr2cRQJVSjx7rBlEb2 U07U4vv+z7WXbgzY4jWWg0gGdeBrG3kGJEu7zGX2ceIHWXuYn+8swxvWWUIYHsLoR7/z JR/BDcRkJ42O3ZrJQJDfkQhJ1zBJgkDUL0zcWeIhKTk5P5VRHLSx1M8znrF8ycHi16DP 7yCONrzDN0V4XdSEXz5VFkMepj7BRGPSnk/r4a0INGR8Nce4LOMMUN6WEjST0OL1f9gO k7dSyVg4DEa4D15qiax9Hv6JRAeWdcpHL59Yyck5oYmFSTk/0QzHVSMABriKMhWm72lk 2uYQ== X-Gm-Message-State: AOJu0YymZgzuAR+AMl0JiLSXrV0d2MWrm9znO67+SdlJ9jzth+Tg6Iv8 vIlB6tb6kmp8MFTT0ZkCNkLJSeiSIijd7NzeN0AieMsZ6eRRgVIJsJMnMw== X-Google-Smtp-Source: AGHT+IFU51alc/p0hhPKhhcdaAdxxfaNF9as20O+YdmVNtIcnlDnj2uqqUyG6PrSdsAgDe8lsDzk4Q== X-Received: by 2002:a17:90a:ca98:b0:2c9:36bf:ba6f with SMTP id 98e67ed59e1d1-2e1e5b30bcemr2815894a91.3.1728030280979; Fri, 04 Oct 2024 01:24:40 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:f861:b057:7729:e742]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e85c18b9sm958881a91.9.2024.10.04.01.24.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 01:24:40 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 611691141336; Fri, 4 Oct 2024 17:54:38 +0930 (ACST) Date: Fri, 4 Oct 2024 17:54:38 +0930 From: Alan Modra To: binutils@sourceware.org Subject: is_target_special_symbol fixes for commit 68bbe1183379 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3032.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This one was found by oss-fuzz. I expect there will be some more. * elf.c (_bfd_elf_is_local_label_name): Don't segv on NULL name. * elf32-v850.c (v850_elf_is_local_label_name): Likewise. * elfnn-riscv.c (riscv_elf_is_target_special_symbol): Likewise. diff --git a/bfd/elf.c b/bfd/elf.c index 39ee641097b..4012d994272 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -9725,6 +9725,9 @@ bool _bfd_elf_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name) { + if (!name) + return false; + /* Normal local symbols start with ``.L''. */ if (name[0] == '.' && name[1] == 'L') return true; diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 85cbcbc3505..8d61ebb6754 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -1933,8 +1933,13 @@ v850_elf_info_to_howto_rela (bfd *abfd, static bool v850_elf_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name) { - return ( (name[0] == '.' && (name[1] == 'L' || name[1] == '.')) - || (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_')); + if (!name) + return false; + if (name[0] == '.' && (name[1] == 'L' || name[1] == '.')) + return true; + if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_') + return true; + return false; } static bool diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 90ecc276f31..4844412a4d4 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -5610,9 +5610,11 @@ riscv_maybe_function_sym (const asymbol *sym, static bool riscv_elf_is_target_special_symbol (bfd *abfd, asymbol *sym) { + if (!sym->name) + return false; /* PR27584, local and empty symbols. Since they are usually generated for pcrel relocations. */ - return (!strcmp (sym->name, "") + return (!sym->name[0] || _bfd_elf_is_local_label_name (abfd, sym->name) /* PR27916, mapping symbols. */ || riscv_elf_is_mapping_symbols (sym->name));