From owner-svn-src-all@freebsd.org Sun Dec 24 16:52:00 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5FA6E9D8F2; Sun, 24 Dec 2017 16:52:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E14C1C27; Sun, 24 Dec 2017 16:52:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBOGpxIf079164; Sun, 24 Dec 2017 16:51:59 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBOGpxpw079162; Sun, 24 Dec 2017 16:51:59 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201712241651.vBOGpxpw079162@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 24 Dec 2017 16:51:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327164 - in head/contrib/binutils: bfd include X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in head/contrib/binutils: bfd include X-SVN-Commit-Revision: 327164 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Dec 2017 16:52:00 -0000 Author: dim Date: Sun Dec 24 16:51:59 2017 New Revision: 327164 URL: https://svnweb.freebsd.org/changeset/base/327164 Log: Fix clang 6.0.0 compiler warnings in binutils Latest clang git has a warning -Wnull-pointer-arithmetic which will trigger a -Werror failure. Addition and subtraction from a null pointer is undefined behaviour and could be optimized into anything. Furthermore, using the difference between two pointers and casting the result back to a pointer is not portable since the size of ptrdiff_t does not necessary have to be the same as size of void* (this happens e.g. on CHERI). Using intptr_t instead fixes this portability issue and the compiler warning. Submitted by; Alexander Richardson Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D12928 MFC after: 3 days Modified: head/contrib/binutils/bfd/elflink.c head/contrib/binutils/include/obstack.h Modified: head/contrib/binutils/bfd/elflink.c ============================================================================== --- head/contrib/binutils/bfd/elflink.c Sun Dec 24 16:39:57 2017 (r327163) +++ head/contrib/binutils/bfd/elflink.c Sun Dec 24 16:51:59 2017 (r327164) @@ -4815,7 +4815,7 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd, len = strlen (name); copy = bfd_alloc (abfd, len); if (copy == NULL) - return (struct elf_link_hash_entry *) 0 - 1; + return (struct elf_link_hash_entry *)(intptr_t)-1; first = p - name + 1; memcpy (copy, name, first); @@ -4927,7 +4927,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_li } h = archive_symbol_lookup (abfd, info, symdef->name); - if (h == (struct elf_link_hash_entry *) 0 - 1) + if (h == (struct elf_link_hash_entry *)(intptr_t)-1) goto error_return; if (h == NULL) Modified: head/contrib/binutils/include/obstack.h ============================================================================== --- head/contrib/binutils/include/obstack.h Sun Dec 24 16:39:57 2017 (r327163) +++ head/contrib/binutils/include/obstack.h Sun Dec 24 16:51:59 2017 (r327164) @@ -119,11 +119,11 @@ extern "C" { may ignore the byte-within-word field of the pointer. */ #ifndef __PTR_TO_INT -# define __PTR_TO_INT(P) ((P) - (char *) 0) +# define __PTR_TO_INT(P) ((intptr_t)(P)) #endif #ifndef __INT_TO_PTR -# define __INT_TO_PTR(P) ((P) + (char *) 0) +# define __INT_TO_PTR(P) ((void*)(intptr_t)(P)) #endif /* We need the type of the resulting object. If __PTRDIFF_TYPE__ is @@ -427,7 +427,7 @@ __extension__ \ __o1->maybe_empty_object = 1; \ __o1->next_free \ = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ + & ~(intptr_t)(__o1->alignment_mask)); \ if (__o1->next_free - (char *)__o1->chunk \ > __o1->chunk_limit - (char *)__o1->chunk) \ __o1->next_free = __o1->chunk_limit; \