summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/bfd/elflink.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2018-01-01 20:39:12 +0000
committerLuiz Souza <luiz@netgate.com>2018-02-21 15:19:51 -0300
commitb042831d7b39460b5b04220cf450867d9dabe394 (patch)
treea069324f1d6fa199f420edbc0ecd3a579e89c906 /contrib/binutils/bfd/elflink.c
parent7f33f93bf2f7c20161a5486c2d80c28c6152969a (diff)
downloadFreeBSD-src-b042831d7b39460b5b04220cf450867d9dabe394.zip
FreeBSD-src-b042831d7b39460b5b04220cf450867d9dabe394.tar.gz
MFC r327164:
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 (cherry picked from commit 0cd25a0c5807abc3eb947abf62bc29f95037eba2)
Diffstat (limited to 'contrib/binutils/bfd/elflink.c')
-rw-r--r--contrib/binutils/bfd/elflink.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c
index 10d987c..2022b96 100644
--- a/contrib/binutils/bfd/elflink.c
+++ b/contrib/binutils/bfd/elflink.c
@@ -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_link_info *info)
}
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)
OpenPOWER on IntegriCloud