From e47ea033a1931637dd28c85745a96b97a12cfdd9 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 13 Jun 2017 01:05:55 +0000 Subject: [PATCH] hexdump: actually enter capability mode on last file Reviewed by: cem, Kyle Evans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10897 --- contrib/llvm/tools/lld/ELF/InputSection.cpp | 12 ++++++------ usr.bin/hexdump/display.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/llvm/tools/lld/ELF/InputSection.cpp b/contrib/llvm/tools/lld/ELF/InputSection.cpp index 6b1e92891b9..36936099011 100644 --- a/contrib/llvm/tools/lld/ELF/InputSection.cpp +++ b/contrib/llvm/tools/lld/ELF/InputSection.cpp @@ -255,7 +255,7 @@ static uint32_t getARMUndefinedRelativeWeakVA(uint32_t Type, uint32_t A, uint32_t P) { switch (Type) { case R_ARM_THM_JUMP11: - return P + 2; + return P + 2 + A; case R_ARM_CALL: case R_ARM_JUMP24: case R_ARM_PC24: @@ -263,12 +263,12 @@ static uint32_t getARMUndefinedRelativeWeakVA(uint32_t Type, uint32_t A, case R_ARM_PREL31: case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP24: - return P + 4; + return P + 4 + A; case R_ARM_THM_CALL: // We don't want an interworking BLX to ARM - return P + 5; + return P + 5 + A; default: - return A; + return P + A; } } @@ -279,9 +279,9 @@ static uint64_t getAArch64UndefinedRelativeWeakVA(uint64_t Type, uint64_t A, case R_AARCH64_CONDBR19: case R_AARCH64_JUMP26: case R_AARCH64_TSTBR14: - return P + 4; + return P + 4 + A; default: - return A; + return P + A; } } diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index be2264a5f0a..f7b19cd466a 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -361,12 +361,12 @@ next(char **argv) if (caph_limit_stream(fileno(stdin), CAPH_READ) < 0) err(1, "unable to restrict %s", - statok ? _argv[-1] : "stdin"); + statok ? *_argv : "stdin"); /* * We've opened our last input file; enter capsicum sandbox. */ - if (*_argv == NULL) { + if (statok == 0 || *(_argv + 1) == NULL) { if (cap_enter() < 0 && errno != ENOSYS) err(1, "unable to enter capability mode"); }