From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id E3FDE381DCF6 for ; Thu, 19 Mar 2020 03:25:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E3FDE381DCF6 Received: by mail-pg1-x532.google.com with SMTP id t3so450268pgn.1 for ; Wed, 18 Mar 2020 20:25:43 -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:subject:message-id:mime-version :content-disposition:user-agent; bh=3LYn0TWBfA33PlhuUy6wxURt5v8Or/cNscqMdnyaEhg=; b=XFFCtr0eyzdLlzf4Xc1QB9lPHckNZ27VMSvQvTHf+xLJCvUHizbx+47Mo2R4UgnfuZ 8PNoW6h92rHHR/wbAohmo3b2Jg2d/1hwDrCiE1qFcM8gc1el6IfyGfJa1YpCQJ99Owrd jDiGk2BWd9VawObvUpe0PLN2+0Am01/125ggHM9JtvRoHpgDck2MxVELrrOni9ynbYdR MvxI6AZy3GxYpgEEH/BAerVRAJOToJ/ivsly6Y/o9D6btwPP3kJl2otam4hkgfdlHBRr mKhGuLJIHrAJscEe9iDdX+wZ14JP1lQGaUnAwJF8jnLqsP5NpRmkrLGQoWkhvIdPCp7K Mr9g== X-Gm-Message-State: ANhLgQ2ZMnaSgXho3i03uKG5w+pUEaSlnwqoj4q3ot0YJ5kzrPUSJia0 Ahd0vk7MEgMBsSA8zeVDlk7RPjlHOmI= X-Google-Smtp-Source: ADFU+vt3Gey1lPpCg4LDQ4j4a6wK7BD4m3keAX1a15RMOssxJFcM1xfMPO3r1jgdzmLPkfEseB/PhQ== X-Received: by 2002:a63:384e:: with SMTP id h14mr1041679pgn.295.1584588342678; Wed, 18 Mar 2020 20:25:42 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id w124sm401051pfd.71.2020.03.18.20.25.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 20:25:42 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 1B722829CB; Thu, 19 Mar 2020 13:55:37 +1030 (ACDT) Date: Thu, 19 Mar 2020 13:55:37 +1030 From: Alan Modra To: binutils@sourceware.org Subject: setup_archive parameter mismatch Message-ID: <20200319032537.GA4583@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS 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: Thu, 19 Mar 2020 03:25:45 -0000 readelf.c and elfedit.c both define BFD64 in order to support processing of ELFCLASS64 objects. Or at least that's what the comment says. This means I should not have used bfd_size_type to pass file size to a function in elfcomm.c which also includes bfd.h but doesn't define BFD64. When you build and test on a 64-bit host, the parameter mismatch doesn't show up, but it does if bfd/ is compiled on a 32-bit host without 64-bit BFD support. * elfcomm.c (setup_archive): Make file_size an off_t. Comment. * elfcomm.h (setup_archive): Update prototype. diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c index e5c6a32c6d..b0fbf57e1f 100644 --- a/binutils/elfcomm.c +++ b/binutils/elfcomm.c @@ -21,6 +21,11 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +/* Do not use BFD types in this file that differ in size depending on + whether BFD64 is defined. Functions in this file are used by + readelf.c and elfedit.c which define BFD64, and by objdump.c which + doesn't. */ + #include "sysdep.h" #include "libiberty.h" #include "filenames.h" @@ -607,7 +612,7 @@ process_archive_index_and_symbols (struct archive_info * arch, int setup_archive (struct archive_info *arch, const char *file_name, - FILE *file, bfd_size_type file_size, + FILE *file, off_t file_size, bfd_boolean is_thin_archive, bfd_boolean read_symbols) { size_t got; @@ -671,7 +676,7 @@ setup_archive (struct archive_info *arch, const char *file_name, return 1; } /* PR 17531: file: 639d6a26. */ - if (arch->longnames_size > file_size + if ((off_t) arch->longnames_size > file_size || (signed long) arch->longnames_size < 0) { error (_("%s: long name table is too big, (size = 0x%lx)\n"), diff --git a/binutils/elfcomm.h b/binutils/elfcomm.h index 731d3dbd34..8d962f2731 100644 --- a/binutils/elfcomm.h +++ b/binutils/elfcomm.h @@ -74,7 +74,7 @@ extern char *adjust_relative_path (const char *, const char *, unsigned long); /* Read the symbol table and long-name table from an archive. */ extern int setup_archive (struct archive_info *, const char *, FILE *, - bfd_size_type, bfd_boolean, bfd_boolean); + off_t, bfd_boolean, bfd_boolean); /* Open and setup a nested archive, if not already open. */ extern int setup_nested_archive (struct archive_info *, const char *); -- Alan Modra Australia Development Lab, IBM