From patchwork Fri Feb 10 00:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 55172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp669567wrn; Thu, 9 Feb 2023 16:57:34 -0800 (PST) X-Google-Smtp-Source: AK7set9EyWOfhPjYxy6bzV1CjpQcr1sgVT48R998NGsPIJV2THQrYD+oY7ej6FDBFCeRBSo5rjya X-Received: by 2002:a50:8ace:0:b0:4aa:a4e6:249b with SMTP id k14-20020a508ace000000b004aaa4e6249bmr14043617edk.7.1675990654783; Thu, 09 Feb 2023 16:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675990654; cv=none; d=google.com; s=arc-20160816; b=X5Tl7OdKBJ6zmhs4BsJjyp/Tmj+F0j+QANKS1gqOCCSvcyy+JjDvyppJwrO1xsWbfE bdCPhEanmIMmi3hAAE6jJ4K3mua4VjUN1/OLtx41itDCb4yoARUF0MatIR95YVAlC+ca 4Fm9I5sYVwZgFM7exwqFKv4bkh2ORf/I0K5I4IYerBZiVQgBwjObiI20H/2HZeeAUePd jrJNjuyrXi2+pCHDZBRAPpLy9f3uOh3l1/WHhqjYYqe1VTsWjTzMKJyMFfPhHIs2kaza UCdz/3AWal4ShF1yXE+5fpN9vv+SxTSU2t3pBlnX46XDPr/p92xgEjKQSIQ47p3dxlPT t0YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=jGKX4ZMO8nMzTXrLYFFr0wqFNrW8yHN6JNTiHT9VPzc=; b=p2eRyWc9TM1nq/jter077PETdngoz4Q8rZV//Y9ks/plNW8MFmuxtfzBP/VUn7i+Rt RRvQAmp/zUw6s7vP/Bf4D2NcEoXfUHevSdGxbXItbES7BbpmCmdSS59AfcNyQNAPLlO7 CZ7OcYtb0O8cZHe3pyIPEGla9K7n2gehiJNdrBHmmn6LMv/Gbcdk8yUkPGN9LpkCZAtH WGcLNtfnUozw+oKn7Usx60kGVCGzeG6fpHEcU+tfuW/S0LpHSUxBwsueCuuyE0EBtPLA V2Pr/BQVvTlQMafJ23md6Sm/gBwb6LfIuIKQqwQNTJPgSvMMIrx7i1tG1H5YRW+IT8CQ 4lpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=cPNiefnN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v9-20020aa7d9c9000000b004a6e361234dsi1948994eds.72.2023.02.09.16.57.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 16:57:34 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=cPNiefnN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B11E38582BC for ; Fri, 10 Feb 2023 00:57:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B11E38582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675990653; bh=jGKX4ZMO8nMzTXrLYFFr0wqFNrW8yHN6JNTiHT9VPzc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cPNiefnNp/gHNKRXgv3Q/EQ6aLaH9fQtNjjduciOFon46B8g/8vIrrCzc8G0/Xlew mbwuTlNZFX+pc/2AhF6nbe/vlxD2855BdGCAVsdc2W1qLmUAzvtu0ofBfyL0jYT9KQ SGeCEA8RJ2Ei18BfEn81ZycaeG32knaRJPueyRcE= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 6A1B83858C5F for ; Fri, 10 Feb 2023 00:57:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A1B83858C5F Received: by mail-pj1-x102e.google.com with SMTP id pj3so3733959pjb.1 for ; Thu, 09 Feb 2023 16:57:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jGKX4ZMO8nMzTXrLYFFr0wqFNrW8yHN6JNTiHT9VPzc=; b=PsZAAM2nSEDkqzJ6vuoXlsUfI4rJI1C3yBIvixHX226shbYGb+xVmMSqPszqWESz+P rb3B604pOZNBXctVRLd+J+kw8F8dldQ7ZnItPfOowsFdeaJBXfQ/JtuDajXQG0FAcV0E JUjznr/mF5v8l+0XcSP1CuF9dO4n116ZCQQTcwTFMdvQHiudmxiYVIDkDrKrecgDnieM j3WhKbXH+viutqEy/L/QddPOlnWwfLP+FbQaGoqvBflWBivkvTsaYQSCiGlnx0oRsZQ0 gTJN3in9pe9gpTLIealJLLBcwejcWPqz2RusArQ23L8AgT87Oz4JhC7AKm0XhauJrh8S 1JOg== X-Gm-Message-State: AO0yUKXYgB8d+oH7tuIvElOsIwBomFcecMNIAOrNy0Mq99L5MATepyAU VZp8ORCGljxGWWLK9kmyRFDYc6ClKVE= X-Received: by 2002:a17:903:2448:b0:198:f027:5925 with SMTP id l8-20020a170903244800b00198f0275925mr15055087pls.64.1675990642051; Thu, 09 Feb 2023 16:57:22 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:2038:210a:86cd:55ab]) by smtp.gmail.com with ESMTPSA id j16-20020a170902759000b00189f2fdbdd0sm2120345pll.234.2023.02.09.16.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 16:57:21 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 0337D114032E; Fri, 10 Feb 2023 11:27:18 +1030 (ACDT) Date: Fri, 10 Feb 2023 11:27:18 +1030 To: binutils@sourceware.org Subject: objcopy of mach-o indirect symbols Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757403576542102099?= X-GMAIL-MSGID: =?utf-8?q?1757403576542102099?= Anti-fuzzer measure. I'm not sure what the correct fix is for objcopy. Probably the BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS, BFD_MACH_O_S_LAZY_SYMBOL_POINTERS and BFD_MACH_O_S_SYMBOL_STUBS contents should be read. * mach-o.c (bfd_mach_o_section_get_nbr_indirect): Omit sections with NULL sec->indirect_syms. diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 15da219ba57..a910e1146ea 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -526,6 +526,15 @@ bfd_mach_o_section_get_nbr_indirect (bfd *abfd, bfd_mach_o_section *sec) { unsigned int elsz; + /* FIXME: This array is set by the assembler but does not seem to be + set anywhere for objcopy. Since bfd_mach_o_build_dysymtab will + not fill in output bfd_mach_o_dysymtab_command indirect_syms when + this array is NULL we may as well return zero for the size. + This is enough to stop objcopy allocating huge amounts of memory + for indirect symbols in fuzzed object files. */ + if (sec->indirect_syms == NULL) + return 0; + elsz = bfd_mach_o_section_get_entry_size (abfd, sec); if (elsz == 0) return 0;