Commit Graph

8140 Commits

Author SHA1 Message Date
Mark Johnston
4a0f8b339e Add DW_LANG_* definitions from DWARF 4 and 5.
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D15712
2018-06-09 14:50:38 +00:00
Kyle Evans
52cf896593 netbsd-tests: bsdgrep(1): Add a test for -m, too 2018-06-07 18:53:39 +00:00
Kyle Evans
ce024bdc0c netbsd-tests: grep(1): Add test for -c flag
Someone might be inclined to accidentally break this. someone might have
written said test because they broke it locally.
2018-06-07 18:06:01 +00:00
Hans Petter Selasky
5fd1ea0810 Re-apply r190640.
- Restore local change to include <net/bpf.h> inside pcap.h.
This fixes ports build problems.
- Update local copy of dlt.h with new DLT types.
- Revert no longer needed <net/bpf.h> includes which were added
as part of r334277.

Suggested by:	antoine@, delphij@, np@
MFC after:	3 weeks
Sponsored by:	Mellanox Technologies
2018-05-31 09:11:21 +00:00
Alan Somers
b3bc3d7925 au_read_rec(3): correct return value in man page
Submitted by:	aniketp
Reviewed by:	csjp (earlier version)
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15618
2018-05-30 17:05:48 +00:00
Alan Somers
6570d61a59 Fix OpenBSM with GCC with -Wredundant-decls
Upstream change ed47534 consciously added some redundant functional
declarations, and I'm not sure why. AFAICT they were never required. On
FreeBSD, they break the build with GCC (but not Clang) for any program
including libbsm.h with WARNS=6.

Fix by cherry-picking upstream change
https://github.com/openbsm/openbsm/commit/0553c27

Reported by:	emaste
Reviewed by:	cem
Obtained from:	OpenBSM
MFC after:	2 weeks
Pull Request:	https://github.com/openbsm/openbsm/pull/31
2018-05-30 15:51:48 +00:00
Hans Petter Selasky
65b806b289 Hide unsupported remote capture definitions to avoid breakage in ports.
Suggested by:	antoine@
MFC after:	3 weeks
Sponsored by:	Mellanox Technologies
2018-05-30 11:45:29 +00:00
Slava Shwartsman
ddeb4e8aa6 MFV r333668:
Vendor import two upstream commits:
c1bb8784abd3ca978e376b0d10e324db0491237b
9c4af7213cc2543a1f5586d8f2c19f86aa0cbe72

When using tcpdump -I -i wlanN and wlanN is not a monitor mode VAP,
tcpdump will print an error message saying rfmon is not supported.

Give a concise explanation as to how one might solve this problem by
creating a monitor mode VAP.

MFC after:      1 month
Approved by:    hselasky (mentor), kib (mentor)
Sponsored by:   Mellanox Technologies
2018-05-29 10:29:04 +00:00
Hans Petter Selasky
b00ab7548b MFV r333789: libpcap 1.9.0 (pre-release)
MFC after:	1 month
Sponsored by:	Mellanox Technologies
2018-05-28 08:12:18 +00:00
Phil Shafer
983afe3373 Import libxo-0.9.0:
- Add xo_format_is_numeric() with improved logic to decide if format
  strings are numeric, so json output quotes them
- Convert docs to sphinx/rst
- update tests

Includes fix for PR 221676:
27d3021cc3 (diff-5a0d468963477f7daedb8308c219dd80)

PR:		 221676
MFC after:	5 days
2018-05-23 01:20:31 +00:00
Antoine Brodin
a665699823 Revert last change to file/magic/Magdir/elf, it misidentifies most shared
libraries installed from ports as pie executables instead of shared libraries,
and consequently breaks ports.
2018-05-20 22:07:44 +00:00
Eitan Adler
58a0f0d00c MFV: file 5.33
Merge the latest file(1) in.

Relevent Changelog:
- extend the support for ${x?:} expansions for magic descriptions
- add support for ${x?:} in mime types to handle pie binaries.
- add support for negative offsets (offsets from the end of file)
- close the file on error when writing magic

Relnotes:	yes
2018-05-20 05:06:42 +00:00
Eitan Adler
3be6ef0659 top(1): Migrate top to usr.bin
We've been maintaining top(1) for a long time, and the upstream
hasn't existed/been used in similarly as long. Make it clear that we own
top(1)

Tested with 'make universe'. Everything passed except MIPS which failed
for unrelated reasons. Install also tested for amd64.

Reviewed by:		sbruno
No objections:		imp, mmacy
Differential Revision:	https://reviews.freebsd.org/D15387
2018-05-19 22:40:23 +00:00
Simon J. Gerraty
494f719155 Merge bmake-20180512
Skip polling job token pipe,
better handle sysV style includes with variables.
2018-05-19 00:26:00 +00:00
Xin LI
b71a5db306 MFV r333779: xz 5.2.4.
MFC after:	2 weeks
2018-05-18 06:10:16 +00:00
Dimitry Andric
54f4b9a61f Pull in r322325 from upstream llvm trunk (by Matthias Braun):
PeepholeOpt cleanup/refactor; NFC

  - Less unnecessary use of `auto`
  - Add early `using RegSubRegPair(AndIdx) =` to avoid countless
    `TargetInstrInfo::` qualifications.
  - Use references instead of pointers where possible.
  - Remove unused parameters.
  - Rewrite the CopyRewriter class hierarchy:
     - Pull out uncoalescable copy rewriting functionality into
       PeepholeOptimizer class.
     - Use an abstract base class to make it clear that rewriters are
       independent.
  - Remove unnecessary \brief in doxygen comments.
  - Remove unused constructor and method from ValueTracker.
  - Replace UseAdvancedTracking of ValueTracker with DisableAdvCopyOpt
    use.

Even though upstream marked this as "No Functional Change", it does
contain some functional changes, and these fix a compiler hang for one
particular source file in the devel/godot port.

PR:		228261
MFC after:	3 days
2018-05-17 14:38:58 +00:00
Phil Shafer
48d41ef0fb Handle thread-local storage (TLS) segments correctly when
copying (objcopy) and displaying (readelf) them.

PR:		227552
Submitted by:	kaiw (maintainer)
Reported by:	jachmann@unitix.org
Reviewed by:	phil
MFC after:	1 day
2018-05-14 05:21:18 +00:00
Dag-Erling Smørgrav
b70d78d6e8 Rename all Unbound binaries and man pages from unbound* to local-unbound*.
PR:		222902
2018-05-12 17:10:36 +00:00
Dag-Erling Smørgrav
0fb349906e Upgrade Unbound to 1.7.1. 2018-05-12 15:20:39 +00:00
Dag-Erling Smørgrav
57bddd215c Upgrade Unbound to 1.7.0. More to follow. 2018-05-12 15:04:05 +00:00
Dag-Erling Smørgrav
838e13ceea Upgrade Unbound to 1.6.8. More to follow. 2018-05-12 14:57:42 +00:00
Dag-Erling Smørgrav
db8dbc29fc No reason to keep this around. 2018-05-12 14:51:53 +00:00
Dag-Erling Smørgrav
8a384985ac Upgrade Unbound to 1.6.7. More to follow. 2018-05-12 14:51:18 +00:00
Dag-Erling Smørgrav
971980c374 Upgrade Unbound to 1.6.6. More to follow. 2018-05-12 14:48:38 +00:00
Dag-Erling Smørgrav
8157cbab02 Upgrade Unbound to 1.6.5. More to follow. 2018-05-12 14:39:41 +00:00
Dag-Erling Smørgrav
c7f4d7ad9b Upgrade Unbound to 1.6.4. More to follow. 2018-05-12 14:36:58 +00:00
Dag-Erling Smørgrav
92bb4ebdc4 Upgrade Unbound to 1.6.3. More to follow. 2018-05-12 14:19:14 +00:00
Dag-Erling Smørgrav
65b390aa03 Upgrade Unbound to 1.6.2. More to follow. 2018-05-12 14:15:39 +00:00
Dag-Erling Smørgrav
3005e0a300 Upgrade Unbound to 1.6.1. More to follow. 2018-05-12 14:04:48 +00:00
Dag-Erling Smørgrav
bc89214039 Upgrade Unbound to 1.6.0. More to follow. 2018-05-12 12:57:34 +00:00
Dag-Erling Smørgrav
986ba33c7a Upgrade LDNS to 1.7.0.
I've been holding back on this because 1.7.0 requires OpenSSL 1.1.0 or
newer for full DANE support.  But we can't wait forever, and nothing in
base uses DANE anyway, so here we go.
2018-05-12 12:00:18 +00:00
Dag-Erling Smørgrav
4289761a7b Vendor import of Unbound 1.7.1. 2018-05-12 11:56:52 +00:00
Dag-Erling Smørgrav
197f1a0fe3 Vendor import of Unbound 1.7.0. 2018-05-12 11:56:38 +00:00
Dag-Erling Smørgrav
2bda7bda43 Vendor import of Unbound 1.6.7. 2018-05-12 11:55:57 +00:00
Dag-Erling Smørgrav
a6c5280ea5 Vendor import of Unbound 1.6.6. 2018-05-12 11:55:17 +00:00
Dag-Erling Smørgrav
15de2de844 Vendor import of Unbound 1.6.4. 2018-05-12 11:54:35 +00:00
Dag-Erling Smørgrav
6cacf549d3 Vendor import of Unbound 1.6.2. 2018-05-12 11:53:39 +00:00
Dag-Erling Smørgrav
fbdb9ac866 Vendor import of Unbound 1.6.1. 2018-05-12 11:49:30 +00:00
Jason Evans
0ef50b4ec8 Update jemalloc to version 5.1.0. 2018-05-11 00:32:31 +00:00
Matt Macy
329d20de97 Revert accidentally commited local change to bmake to prevent debilitating
excess system time from poor API usage.

Approved by:	sbruno@
2018-05-10 17:57:46 +00:00
Matt Macy
06bf2a6aef Add simple preempt safe epoch API
Read locking is over used in the kernel to guarantee liveness. This API makes
it easy to provide livenes guarantees without atomics.

Includes epoch_test kernel module to stress test the API.

Documentation will follow initial use case.

Test case and improvements to preemption handling in response to discussion
with mjg@

Reviewed by:	imp@, shurd@
Approved by:	sbruno@
2018-05-10 17:55:24 +00:00
Ed Maste
19703503ba lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC
A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD.  Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info.  lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR:	https://llvm.org/pr37361
LLVM review:	https://reviews.llvm.org/D46623

PR:		226872
Reviewed by:	dim
Sponsored by:	The FreeBSD Foundation
2018-05-09 11:17:01 +00:00
Peter Wemm
7725780a60 Update svn-1.9.7 to 1.10.0. 2018-05-08 04:52:52 +00:00
Peter Wemm
54a411221f Update private sqlite from sqlite3-3.20.0 to sqlite3-3.23.1 2018-05-08 04:51:15 +00:00
Philip Paeps
d81c2dd921 Import tzdata 2018e
Changes: https://github.com/eggert/tz/blob/2018e/NEWS

MFC after:	3 days
2018-05-04 10:17:27 +00:00
Slava Shwartsman
37e576b25e libibumad/umad.c: In get_port, ignore sysctl get rate errors
This can cause ibpanic in ibstat when width is not set properly
as can occur when Ethernet port is connected to InfiniBand fabric.

ibpanic: [8167] main: stat of IB device 'mlx5_0' failed: m

With this change, Rate is displayed as 0 with ibstat for
this scenario.

MFC after:      3 days
Approved by:    hselasky (mentor), kib (mentor)
Sponsored by:   Mellanox Technologies
2018-04-30 15:23:45 +00:00
Ed Maste
715d1396d6 Update ELF Tool Chain to r3614
MFC after:	1 week
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2018-04-27 13:59:24 +00:00
Ed Maste
7165bb8cc6 lldb: remove assertion that target_arch is FreeBSD
The target is not necessarily a FreeBSD binary - for example, it may be
a Linux binary running under the linuxulator.  Basic ptrace (live)
debugging already worked in this case, except for the assertion.

Sponsored by:	Turing Robotic Industries Inc.
2018-04-24 19:26:58 +00:00
Dimitry Andric
5d2c81d91b Pull in r329771 from upstream llvm trunk (by Craig Topper):
[X86] In X86FlagsCopyLowering, when rewriting a memory setcc we need
  to emit an explicit MOV8mr instruction.

  Previously the code only knew how to handle setcc to a register.

  This should fix a crash in the chromium build.

This fixes various assertion failures while building ports targeting
i386:
* www/firefox: isReg() && "This is not a register operand!"
* www/iridium, www/qt5-webengine: (I.atEnd() || std::next(I) ==
  def_instr_end()) && "getVRegDef assumes a single definition or no
  definition"
* devel/powerpc64-gcc: FromReg != ToReg && "Cannot replace a reg with
  itself"

Reported by:	jbeich
PR:		225330, 227686, 227698, 227699
MFC after:	1 week
X-MFC-With:	r332833
2018-04-23 23:07:57 +00:00
Hans Petter Selasky
2a2234c0f4 Remove the "load drivers" logic from libibverbs.
The "load drivers" logic in the libibverbs configuration file is relevant
for Linux only.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2018-04-22 06:11:46 +00:00
Ed Maste
69dcf941a4 lldb: propagate error to user if memory read fails
Previously, an attempt to read an unreadable access reported zeros:

(lldb) memory read -format hex -size 8 0
0x00000000: 0x0000000000000000 0x0000000000000000
0x00000010: 0x0000000000000000 0x0000000000000000
...

Now, if DoReadMemory encounters error then return 0 (bytes read) so we
report the error to the user:

(lldb) memory read -format hex -size 8 0
error: Bad address

LLVM PR:	37190

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-04-21 00:34:46 +00:00
Dimitry Andric
0556cfadc2 Recommit r332501, with an additional upstream fix for "Cannot lower
EFLAGS copy that lives out of a basic block!" errors on i386.

Pull in r325446 from upstream clang trunk (by me):

  [X86] Add 'sahf' CPU feature to frontend

  Summary:
  Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
  `+sahf` feature for the backend, for bug 36028 (Incorrect use of
  pushf/popf enables/disables interrupts on amd64 kernels).  This was
  originally submitted in bug 36037 by Jonathan Looney
  <jonlooney@gmail.com>.

  As described there, GCC also uses `-msahf` for this feature, and the
  backend already recognizes the `+sahf` feature. All that is needed is
  to teach clang to pass this on to the backend.

  The mapping of feature support onto CPUs may not be complete; rather,
  it was chosen to match LLVM's idea of which CPUs support this feature
  (see lib/Target/X86/X86.td).

  I also updated the affected test case (CodeGen/attr-target-x86.c) to
  match the emitted output.

  Reviewers: craig.topper, coby, efriedma, rsmith

  Reviewed By: craig.topper

  Subscribers: emaste, cfe-commits

  Differential Revision: https://reviews.llvm.org/D43394

Pull in r328944 from upstream llvm trunk (by Chandler Carruth):

  [x86] Expose more of the condition conversion routines in the public
  API for X86's instruction information. I've now got a second patch
  under review that needs these same APIs. This bit is nicely
  orthogonal and obvious, so landing it. NFC.

Pull in r329414 from upstream llvm trunk (by Craig Topper):

  [X86] Merge itineraries for CLC, CMC, and STC.

  These are very simple flag setting instructions that appear to only
  be a single uop. They're unlikely to need this separation.

Pull in r329657 from upstream llvm trunk (by Chandler Carruth):

  [x86] Introduce a pass to begin more systematically fixing PR36028
  and similar issues.

  The key idea is to lower COPY nodes populating EFLAGS by scanning the
  uses of EFLAGS and introducing dedicated code to preserve the
  necessary state in a GPR. In the vast majority of cases, these uses
  are cmovCC and jCC instructions. For such cases, we can very easily
  save and restore the necessary information by simply inserting a
  setCC into a GPR where the original flags are live, and then testing
  that GPR directly to feed the cmov or conditional branch.

  However, things are a bit more tricky if arithmetic is using the
  flags.  This patch handles the vast majority of cases that seem to
  come up in practice: adc, adcx, adox, rcl, and rcr; all without
  taking advantage of partially preserved EFLAGS as LLVM doesn't
  currently model that at all.

  There are a large number of operations that techinaclly observe
  EFLAGS currently but shouldn't in this case -- they typically are
  using DF.  Currently, they will not be handled by this approach.
  However, I have never seen this issue come up in practice. It is
  already pretty rare to have these patterns come up in practical code
  with LLVM. I had to resort to writing MIR tests to cover most of the
  logic in this pass already.  I suspect even with its current amount
  of coverage of arithmetic users of EFLAGS it will be a significant
  improvement over the current use of pushf/popf. It will also produce
  substantially faster code in most of the common patterns.

  This patch also removes all of the old lowering for EFLAGS copies,
  and the hack that forced us to use a frame pointer when EFLAGS copies
  were found anywhere in a function so that the dynamic stack
  adjustment wasn't a problem. None of this is needed as we now lower
  all of these copies directly in MI and without require stack
  adjustments.

  Lots of thanks to Reid who came up with several aspects of this
  approach, and Craig who helped me work out a couple of things
  tripping me up while working on this.

  Differential Revision: https://reviews.llvm.org/D45146

Pull in r329673 from upstream llvm trunk (by Chandler Carruth):

  [x86] Model the direction flag (DF) separately from the rest of
  EFLAGS.

  This cleans up a number of operations that only claimed te use EFLAGS
  due to using DF. But no instructions which we think of us setting
  EFLAGS actually modify DF (other than things like popf) and so this
  needlessly creates uses of EFLAGS that aren't really there.

  In fact, DF is so restrictive it is pretty easy to model. Only STD,
  CLD, and the whole-flags writes (WRFLAGS and POPF) need to model
  this.

  I've also somewhat cleaned up some of the flag management instruction
  definitions to be in the correct .td file.

  Adding this extra register also uncovered a failure to use the
  correct datatype to hold X86 registers, and I've corrected that as
  necessary here.

  Differential Revision: https://reviews.llvm.org/D45154

Pull in r330264 from upstream llvm trunk (by Chandler Carruth):

  [x86] Fix PR37100 by teaching the EFLAGS copy lowering to rewrite
  uses across basic blocks in the limited cases where it is very
  straight forward to do so.

  This will also be useful for other places where we do some limited
  EFLAGS propagation across CFG edges and need to handle copy rewrites
  afterward. I think this is rapidly approaching the maximum we can and
  should be doing here. Everything else begins to require either heroic
  analysis to prove how to do PHI insertion manually, or somehow
  managing arbitrary PHI-ing of EFLAGS with general PHI insertion.
  Neither of these seem at all promising so if those cases come up,
  we'll almost certainly need to rewrite the parts of LLVM that produce
  those patterns.

  We do now require dominator trees in order to reliably diagnose
  patterns that would require PHI nodes. This is a bit unfortunate but
  it seems better than the completely mysterious crash we would get
  otherwise.

  Differential Revision: https://reviews.llvm.org/D45673

Together, these should ensure clang does not use pushf/popf sequences to
save and restore flags, avoiding problems with unrelated flags (such as
the interrupt flag) being restored unexpectedly.

Requested by:	jtl
PR:		225330
MFC after:	1 week
2018-04-20 18:20:55 +00:00
Kurt Lidl
c382392d70 top: fix warnings from clang/gcc
Add includes for <curses.h> and <termcap.h> where necessary, and
rename a few internal functions to have a "top_" prefix to avoid
clashes with standard names from curses.h/termcap.h headers.

Top now compiles without warnings on both gcc and clang.

Reviewed by:	emaste, imp, jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D15115
2018-04-18 13:17:14 +00:00
Edward Tomasz Napierala
604f1c416c Don't put multiple names on a single .Nm line. This fixes apropos(1)
output, from this:

strnlen, strlen, strlen,(3) - find length of string                                                                                                                                                     │·······

... to this:

strlen, strnlen(3) - find length of string

PR:		223525
MFC after:	2 weeks
2018-04-17 09:05:46 +00:00
Eitan Adler
881597c36c amd: correct formatting of 'SEE ALSO' 2018-04-14 21:54:22 +00:00
Dimitry Andric
6ec30ab86a Revert r332501 for now, as it can cause build failures on i386.
Reported upstream as <https://bugs.llvm.org/show_bug.cgi?id=37133>.

Reported by:	emaste, ci.freebsd.org
PR:		225330
2018-04-14 14:57:32 +00:00
Dimitry Andric
0ae629bdd6 Pull in r325446 from upstream clang trunk (by me):
[X86] Add 'sahf' CPU feature to frontend

  Summary:
  Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
  `+sahf` feature for the backend, for bug 36028 (Incorrect use of
  pushf/popf enables/disables interrupts on amd64 kernels).  This was
  originally submitted in bug 36037 by Jonathan Looney
  <jonlooney@gmail.com>.

  As described there, GCC also uses `-msahf` for this feature, and the
  backend already recognizes the `+sahf` feature. All that is needed is
  to teach clang to pass this on to the backend.

  The mapping of feature support onto CPUs may not be complete; rather,
  it was chosen to match LLVM's idea of which CPUs support this feature
  (see lib/Target/X86/X86.td).

  I also updated the affected test case (CodeGen/attr-target-x86.c) to
  match the emitted output.

  Reviewers: craig.topper, coby, efriedma, rsmith

  Reviewed By: craig.topper

  Subscribers: emaste, cfe-commits

  Differential Revision: https://reviews.llvm.org/D43394

Pull in r328944 from upstream llvm trunk (by Chandler Carruth):

  [x86] Expose more of the condition conversion routines in the public
  API for X86's instruction information. I've now got a second patch
  under review that needs these same APIs. This bit is nicely
  orthogonal and obvious, so landing it. NFC.

Pull in r329414 from upstream llvm trunk (by Craig Topper):

  [X86] Merge itineraries for CLC, CMC, and STC.

  These are very simple flag setting instructions that appear to only
  be a single uop. They're unlikely to need this separation.

Pull in r329657 from upstream llvm trunk (by Chandler Carruth):

  [x86] Introduce a pass to begin more systematically fixing PR36028
  and similar issues.

  The key idea is to lower COPY nodes populating EFLAGS by scanning the
  uses of EFLAGS and introducing dedicated code to preserve the
  necessary state in a GPR. In the vast majority of cases, these uses
  are cmovCC and jCC instructions. For such cases, we can very easily
  save and restore the necessary information by simply inserting a
  setCC into a GPR where the original flags are live, and then testing
  that GPR directly to feed the cmov or conditional branch.

  However, things are a bit more tricky if arithmetic is using the
  flags.  This patch handles the vast majority of cases that seem to
  come up in practice: adc, adcx, adox, rcl, and rcr; all without
  taking advantage of partially preserved EFLAGS as LLVM doesn't
  currently model that at all.

  There are a large number of operations that techinaclly observe
  EFLAGS currently but shouldn't in this case -- they typically are
  using DF.  Currently, they will not be handled by this approach.
  However, I have never seen this issue come up in practice. It is
  already pretty rare to have these patterns come up in practical code
  with LLVM. I had to resort to writing MIR tests to cover most of the
  logic in this pass already.  I suspect even with its current amount
  of coverage of arithmetic users of EFLAGS it will be a significant
  improvement over the current use of pushf/popf. It will also produce
  substantially faster code in most of the common patterns.

  This patch also removes all of the old lowering for EFLAGS copies,
  and the hack that forced us to use a frame pointer when EFLAGS copies
  were found anywhere in a function so that the dynamic stack
  adjustment wasn't a problem. None of this is needed as we now lower
  all of these copies directly in MI and without require stack
  adjustments.

  Lots of thanks to Reid who came up with several aspects of this
  approach, and Craig who helped me work out a couple of things
  tripping me up while working on this.

  Differential Revision: https://reviews.llvm.org/D45146

Pull in r329673 from upstream llvm trunk (by Chandler Carruth):

  [x86] Model the direction flag (DF) separately from the rest of
  EFLAGS.

  This cleans up a number of operations that only claimed te use EFLAGS
  due to using DF. But no instructions which we think of us setting
  EFLAGS actually modify DF (other than things like popf) and so this
  needlessly creates uses of EFLAGS that aren't really there.

  In fact, DF is so restrictive it is pretty easy to model. Only STD,
  CLD, and the whole-flags writes (WRFLAGS and POPF) need to model
  this.

  I've also somewhat cleaned up some of the flag management instruction
  definitions to be in the correct .td file.

  Adding this extra register also uncovered a failure to use the
  correct datatype to hold X86 registers, and I've corrected that as
  necessary here.

  Differential Revision: https://reviews.llvm.org/D45154

Together, these should ensure clang does not use pushf/popf sequences to
save and restore flags, avoiding problems with unrelated flags (such as
the interrupt flag) being restored unexpectedly.

Requested by:	jtl
PR:		225330
MFC after:	1 week
2018-04-14 12:07:05 +00:00
Brooks Davis
3a4fc8a8a1 Remove support for the Arcnet protocol.
While Arcnet has some continued deployment in industrial controls, the
lack of drivers for any of the PCI, USB, or PCIe NICs on the market
suggests such users aren't running FreeBSD.

Evidence in the PR database suggests that the cm(4) driver (our sole
Arcnet NIC) was broken in 5.0 and has not worked since.

PR:		182297
Reviewed by:	jhibbits, vangyzen
Relnotes:	yes
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15057
2018-04-13 21:18:04 +00:00
Ruslan Bukin
17f651708e Import OpenCSD -- an ARM CoreSight(tm) Trace Decode Library.
Sponsored by:	DARPA, AFRL
2018-04-04 12:55:31 +00:00
Dimitry Andric
222ab3169e Pull in r328738 from upstream lld trunk (by Rafael Espindola):
Strip @VER suffices from the LTO output.

  This fixes pr36623.

  The problem is that we have to parse versions out of names before LTO
  so that LTO can use that information.

  When we get the LTO produced .o files, we replace the previous symbols
  with the LTO produced ones, but they still have @ in their names.

  We could just trim the name directly, but calling parseSymbolVersion
  to do it is simpler.

This is a follow-up to r331366, since we discovered that lld could
append version strings to symbols twice, when using Link Time
Optimization.

MFC after:	3 months
X-MFC-With:	r327952
2018-03-29 13:55:23 +00:00
Philip Paeps
46bee4edc2 Import tzdata 2018d
Changes: https://github.com/eggert/tz/blob/2018d/NEWS

MFC after:	3 days
2018-03-24 04:52:29 +00:00
Dimitry Andric
ad414d8634 Pull in r327101 from upstream llvm trunk (by Rafael Espindola):
Don't treat .symver as a regular alias definition.

  This patch starts simplifying the handling of .symver.

  For now it just moves the responsibility for creating an alias down to
  the streamer. With that the asm streamer can pass a .symver unchanged,
  which is nice since gas cannot parse "foo@bar = zed".

  In a followup I hope to move the handling down to the writer so that
  we don't need special hacks for avoiding breaking names with @@@ on
  windows.

Pull in r327160 from upstream llvm trunk (by Rafael Espindola):

  Delay creating an alias for @@@.

  With this we only create an alias for @@@ once we know if it should
  use @ or @@. This avoids last minutes renames and hacks to handle MS
  names.

  This only handles the ELF writer. LTO still has issues with @@@
  aliases.

Pull in r327928 from upstream llvm trunk (by Vitaly Buka):

  Object: Move attribute calculation into RecordStreamer. NFC

  Summary: Preparation for D44274

  Reviewers: pcc, espindola

  Subscribers: hiraditya

  Differential Revision: https://reviews.llvm.org/D44276

Pull in r327930 from upstream llvm trunk (by Vitaly Buka):

  Object: Fix handling of @@@ in .symver directive

  Summary:
  name@@@nodename is going to be replaced with name@@nodename if symbols is
  defined in the assembled file, or name@nodename if undefined.
  https://sourceware.org/binutils/docs/as/Symver.html

  Fixes PR36623

  Reviewers: pcc, espindola

  Subscribers: mehdi_amini, hiraditya

  Differential Revision: https://reviews.llvm.org/D44274

Together, these changes fix handling of @@@ in .symver directives when
doing Link Time Optimization.

Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>
MFC after:	3 months
X-MFC-With:	r327952
2018-03-22 18:58:34 +00:00
John Baldwin
1e18e7d203 Add support for MIPS to LLVM's libunwind.
This is originally based on a patch from David Chisnall for soft-float
N64 but has since been updated to support O32, N32, and hard-float ABIs.
The soft-float O32, N32, and N64 support has been committed upstream.
The hard-float changes are still in review upstream.

Enable LLVM_LIBUNWIND on mips when building with a suitable (C+11-capable)
toolchain.  This has been tested with external GCC for all ABIs and
O32 and N64 with clang.

Reviewed by:	emaste
Obtained from:	CheriBSD (original N64 patch)
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D14701
2018-03-20 15:44:17 +00:00
Conrad Meyer
bf799c28ff blacklist: Fix minor memory leak in configuration parsing error case
Ordinarily, the continue clause of the for-loop would free 'line.'  In this
case we instead return early, missing the free.  Add an explicit free to
avoid the leak.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-20 00:16:24 +00:00
Ruslan Bukin
74fe6c29fb Import Intel Processor Trace decoder library from
vendor/processor-trace/24982c1a6fce48f1e416461d42899805f74fbb26

Sponsored by:	DARPA, AFRL
2018-03-19 18:59:15 +00:00
Conrad Meyer
48fc14c0aa elftoolchain nm(1): Initialize allocated memory before use
In out of memory scenarios (where one of these allocations failed but
other(s) did not), nm(1) could reference the uninitialized value of these
allocations (undefined behavior).

Always initialize any successful allocations as the most expedient
resolution of the issue.  However, I would encourage upstream elftoolchain
contributors to clean up the error path to just abort immediately, rather
than proceeding sloppily when one allocation fails.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-16 22:25:33 +00:00
Conrad Meyer
2c710c67d4 telnetd(8): Fix dereference of uninitialized value 'IF'
Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-16 20:59:56 +00:00
Dimitry Andric
bf22ec69ef Pull in r321999 from upstream clang trunk (by Ivan A. Kosarev):
[CodeGen] Fix TBAA info for accesses to members of base classes

  Resolves:
  Bug 35724 - regression (r315984): fatal error: error in backend:
  Broken function found (Did not see access type in access path!)
  https://bugs.llvm.org/show_bug.cgi?id=35724

  Differential Revision: https://reviews.llvm.org/D41547

This fixes "Did not see access type in access path" fatal errors when
building the devel/gdb port (version 8.1).

Reported by:	jbeich
PR:		226658
MFC after:	3 months
X-MFC-With:	r327952
2018-03-16 18:04:13 +00:00
Dimitry Andric
077d36ae02 Pull in r327638 from upstream llvm trunk (by Matthew Simpson):
[ConstantFolding, InstSimplify] Handle more vector GEPs

  This patch addresses some additional cases where the compiler crashes
  upon encountering vector GEPs. This should fix PR36116.

  Differential Revision: https://reviews.llvm.org/D44219
  Reference: https://bugs.llvm.org/show_bug.cgi?id=36116

This fixes an assertion when building the emulators/snes9x port.

Reported by:	jbeich
PR:		225471
MFC after:	3 months
X-MFC-With:	r327952
2018-03-16 17:50:44 +00:00
Dimitry Andric
a3fedceefa Pull in r326882 from upstream llvm trunk (by Sjoerd Meijer):
[ARM] Fix for PR36577

  Don't PerformSHLSimplify if the given node is used by a node that
  also uses a constant because we may get stuck in an infinite combine
  loop.

  bugzilla: https://bugs.llvm.org/show_bug.cgi?id=36577

  Patch by Sam Parker.

  Differential Revision: https://reviews.llvm.org/D44097

This fixes a hang when compiling one particular file in java/openjdk8
for armv6 and armv7.

Reported by:	swills
PR:		226388
2018-03-09 09:21:22 +00:00
Dimitry Andric
c5a4cd4f85 Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes:	yes
MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-03-04 17:06:37 +00:00
Brooks Davis
75c1df31cf Fix build post r330299 2018-03-02 23:31:55 +00:00
Brooks Davis
6d0fe480a8 Don't declare union semun in userspace unless _WANT_SEMUN is defined.
POSIX explicitly states that the application must declare union semun.
This makes no sense, but it is what it is.  This brings us into line
with Linux, MacOS/Darwin, and NetBSD.

In a ports exp-run a moderate number of ports fail due to a lack of
approprate autotools-like discovery mechanisms or local patches.  A
commit to address them will follow shortly.

PR:		224300, 224443 (exp-run)
Reviewed by:	emaste, jhb, kib
Exp-run by:	antoine
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14492
2018-03-02 22:32:53 +00:00
Simon J. Gerraty
50d2e745fa Update to bmake-201802222
Fixes segfault in Var_Set if val is NULL
Don't treat .info as warning with -W
2018-03-02 01:53:50 +00:00
Xin LI
0910025859 MFV r330102: ntp 4.2.8p11 2018-02-28 07:59:55 +00:00
Dimitry Andric
4f8786afe3 Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932).  This corresponds to 6.0.0 rc3.

MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-02-25 13:20:32 +00:00
Warner Losh
ef1fcaf0f5 Do not include float interfaces when using libsa.
We don't support float in the boot loaders, so don't include
interfaces for float or double in systems headers. In addition, take
the unusual step of spiking double and float to prevent any more
accidental seepage.
2018-02-23 04:04:25 +00:00
Warner Losh
07c17b2b00 When the LUA_FLOAT_TYPE != LUA_FLOAT_INT64, we can't reference float
or double so ifdef that code out when the numbers aren't float at all.

There's still references in the lmathlib.c, but we don't compile that
for the loader yet.

Differential Revision: https://reviews.freebsd.org/D14472
2018-02-23 04:04:18 +00:00
Xin LI
74709ed038 MFV r329552: less v530.
MFC after:	2 weeks
2018-02-19 05:10:22 +00:00
Dimitry Andric
954b921d66 Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-02-16 20:45:32 +00:00
Bryan Drewery
70c144dc78 nanosleep(2): Fix bogus incrementing of rmtp by tc_tick_sbt on [EINTR].
sbt is the time in the future that the tsleep_sbt() is expected to be completed
at.  sbtt is the current time.  Depending on the precision with sysctl
kern.timecounter.alloweddeviation the start time may be incremented by
tc_tick_sbt.  The same increment is needed for the current time of sbtt before
calculating the difference.  The impact of missing this increment is that rmtp
may increase by one tc_tick_sbt on every early [EINTR] return.  If the same
struct is passed in for rqtp as rmtp this can result in rqtp effectively
incrementing by tc_tick_sbt and sleeping longer than originally intended.

This problem was introduced in r247797.

Reviewed by:	kib, markj, vangyzen (all on an older version of the test)
MFC after:	2 weeks
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D14362
2018-02-14 18:43:50 +00:00
Alan Somers
fa82818f1d Fix Coverity CIDs in the sys/kern/sysv_test tests
CID 979810: strcpy => strlcpy
CID 1193367: don't leak a file descriptor
CID 1299856: Check the return value of read(2)

Reported by:	Coverity
Coverity CID:	978910 1193367 1299856
MFC after:	3 weeks
X-MFC-With:	328896
Sponsored by:	Spectra Logic Corp
2018-02-13 19:17:33 +00:00
Dimitry Andric
fc9687ba64 Pull in r323998 from upstream clang trunk (by Richard Smith):
PR36157: When injecting an implicit function declaration in C89, find
  the right DeclContext rather than injecting it wherever we happen to
  be.

  This avoids creating functions whose DeclContext is a struct or
  similar.

This fixes assertion failures when parsing certain not-completely-valid
struct declarations.

Reported by:	ae
PR:		225862
MFC after:	3 months
X-MFC-With:	r327952
2018-02-13 17:05:50 +00:00
Alan Somers
dc4e221c3a Convert tools/regression/sockets/socketpair to ATF
Reviewed by:	cem
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D14305
2018-02-10 19:43:52 +00:00
Dimitry Andric
b1562cfa89 Pull in r324594 from upstream clang trunk (by Alexander Ivchenko):
Fix for #31362 - ms_abi is implemented incorrectly for values >=16
  bytes.

  Summary:
  This patch is a fix for following issue:
  https://bugs.llvm.org/show_bug.cgi?id=31362 The problem was caused by
  front end lowering C calling conventions without taking into account
  calling conventions enforced by attribute. In this case win64cc was
  no correctly lowered on targets other than Windows.

  Reviewed By: rnk (Reid Kleckner)

  Differential Revision: https://reviews.llvm.org/D43016

  Author: belickim <mateusz.belicki@intel.com>

This fixes clang 6.0.0 assertions when building the emulators/wine and
emulators/wine-devel ports, and should also make it use the correct
Windows calling conventions.  Bump __FreeBSD_version to make the fix
easy to detect.

PR:		224863
MFC after:	3 months
X-MFC-With:	r327952
2018-02-08 21:11:48 +00:00
John Baldwin
a1d39c5344 Use a workaround to compile the crt init functions correctly with clang.
The MIPS assembly parser treats forward-declared local symbols as global
symbols.  This results in CALL16 relocations being used against local
(private) symbols which then fail to resolve when linking binaries.
Add .local to force the init and fini functions to be treated as local as
a workaround.

Submitted by:	sbruno
Sponsored by:	DARPA / AFRL
2018-02-06 17:01:10 +00:00
Baptiste Daroussin
8134347f26 Remove libreadline from the source tree, all consumers but gdb
has been switched to libedit long ago, libreadline was built as an
internallib for a while and kept only for gdbtui which was broken using
libreadline.

Since gdb has been mostly deorbitted in all arches, gdbtui was only installed
on arm and sparc64, given it has been removed, gdb has been switched to use
libedit, no consumers are left for libreadline. Thus this removal
2018-02-06 12:22:42 +00:00
Baptiste Daroussin
0b0d729237 Commit forgotten change in gdb allowing to use libedit 2018-02-06 12:17:03 +00:00
Brooks Davis
5e1e3ea237 Fix and enable SysV IPC tests.
Don't declare some types that FreeBSD incorrectly declares.

Fix an incorrect call to open() (missing mode).

ANSIfy prototypes.

Enable SysV message queue, semaphore, and shared memory tests.

With exception of the workaround for union semun, these fixes have been
committed to NetBSD.

Reviewed by:	asomers
Approved by:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13471
2018-02-05 18:48:00 +00:00
Kurt Lidl
549f31e459 Update blacklist-helper to not emit messages from pf during operation.
Use 'pfctl -k' when blocking a site to kill active tcp connections
from the blocked address.

Fix 'purge' operation for pf, which must dynamically determine which
filters have been created, so the filters can be flushed by name.

MFC after:	2 weeks
2018-02-04 19:43:51 +00:00
Dimitry Andric
07577dfe2e Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag.  The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation.  Quoting:

  Introduce the "retpoline" x86 mitigation technique for variant #2 of
  the speculative execution vulnerabilities disclosed today,
  specifically identified by CVE-2017-5715, "Branch Target Injection",
  and is one of the two halves to Spectre.

  Summary:
  First, we need to explain the core of the vulnerability. Note that
  this is a very incomplete description, please see the Project Zero
  blog post for details:
  https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

  The basis for branch target injection is to direct speculative
  execution of the processor to some "gadget" of executable code by
  poisoning the prediction of indirect branches with the address of
  that gadget. The gadget in turn contains an operation that provides a
  side channel for reading data. Most commonly, this will look like a
  load of secret data followed by a branch on the loaded value and then
  a load of some predictable cache line. The attacker then uses timing
  of the processors cache to determine which direction the branch took
  *in the speculative execution*, and in turn what one bit of the
  loaded value was. Due to the nature of these timing side channels and
  the branch predictor on Intel processors, this allows an attacker to
  leak data only accessible to a privileged domain (like the kernel)
  back into an unprivileged domain.

  The goal is simple: avoid generating code which contains an indirect
  branch that could have its prediction poisoned by an attacker. In
  many cases, the compiler can simply use directed conditional branches
  and a small search tree. LLVM already has support for lowering
  switches in this way and the first step of this patch is to disable
  jump-table lowering of switches and introduce a pass to rewrite
  explicit indirectbr sequences into a switch over integers.

  However, there is no fully general alternative to indirect calls. We
  introduce a new construct we call a "retpoline" to implement indirect
  calls in a non-speculatable way. It can be thought of loosely as a
  trampoline for indirect calls which uses the RET instruction on x86.
  Further, we arrange for a specific call->ret sequence which ensures
  the processor predicts the return to go to a controlled, known
  location. The retpoline then "smashes" the return address pushed onto
  the stack by the call with the desired target of the original
  indirect call. The result is a predicted return to the next
  instruction after a call (which can be used to trap speculative
  execution within an infinite loop) and an actual indirect branch to
  an arbitrary address.

  On 64-bit x86 ABIs, this is especially easily done in the compiler by
  using a guaranteed scratch register to pass the target into this
  device.  For 32-bit ABIs there isn't a guaranteed scratch register
  and so several different retpoline variants are introduced to use a
  scratch register if one is available in the calling convention and to
  otherwise use direct stack push/pop sequences to pass the target
  address.

  This "retpoline" mitigation is fully described in the following blog
  post: https://support.google.com/faqs/answer/7625886

  We also support a target feature that disables emission of the
  retpoline thunk by the compiler to allow for custom thunks if users
  want them.  These are particularly useful in environments like
  kernels that routinely do hot-patching on boot and want to hot-patch
  their thunk to different code sequences. They can write this custom
  thunk and use `-mretpoline-external-thunk` *in addition* to
  `-mretpoline`. In this case, on x86-64 thu thunk names must be:
  ```
    __llvm_external_retpoline_r11
  ```
  or on 32-bit:
  ```
    __llvm_external_retpoline_eax
    __llvm_external_retpoline_ecx
    __llvm_external_retpoline_edx
    __llvm_external_retpoline_push
  ```
  And the target of the retpoline is passed in the named register, or in
  the case of the `push` suffix on the top of the stack via a `pushl`
  instruction.

  There is one other important source of indirect branches in x86 ELF
  binaries: the PLT. These patches also include support for LLD to
  generate PLT entries that perform a retpoline-style indirection.

  The only other indirect branches remaining that we are aware of are
  from precompiled runtimes (such as crt0.o and similar). The ones we
  have found are not really attackable, and so we have not focused on
  them here, but eventually these runtimes should also be replicated for
  retpoline-ed configurations for completeness.

  For kernels or other freestanding or fully static executables, the
  compiler switch `-mretpoline` is sufficient to fully mitigate this
  particular attack. For dynamic executables, you must compile *all*
  libraries with `-mretpoline` and additionally link the dynamic
  executable and all shared libraries with LLD and pass `-z
  retpolineplt` (or use similar functionality from some other linker).
  We strongly recommend also using `-z now` as non-lazy binding allows
  the retpoline-mitigated PLT to be substantially smaller.

  When manually apply similar transformations to `-mretpoline` to the
  Linux kernel we observed very small performance hits to applications
  running typic al workloads, and relatively minor hits (approximately
  2%) even for extremely syscall-heavy applications. This is largely
  due to the small number of indirect branches that occur in
  performance sensitive paths of the kernel.

  When using these patches on statically linked applications,
  especially C++ applications, you should expect to see a much more
  dramatic performance hit. For microbenchmarks that are switch,
  indirect-, or virtual-call heavy we have seen overheads ranging from
  10% to 50%.

  However, real-world workloads exhibit substantially lower performance
  impact. Notably, techniques such as PGO and ThinLTO dramatically
  reduce the impact of hot indirect calls (by speculatively promoting
  them to direct calls) and allow optimized search trees to be used to
  lower switches. If you need to deploy these techniques in C++
  applications, we *strongly* recommend that you ensure all hot call
  targets are statically linked (avoiding PLT indirection) and use both
  PGO and ThinLTO. Well tuned servers using all of these techniques saw
  5% - 10% overhead from the use of retpoline.

  We will add detailed documentation covering these components in
  subsequent patches, but wanted to make the core functionality
  available as soon as possible. Happy for more code review, but we'd
  really like to get these patches landed and backported ASAP for
  obvious reasons. We're planning to backport this to both 6.0 and 5.0
  release streams and get a 5.0 release with just this cherry picked
  ASAP for distros and vendors.

  This patch is the work of a number of people over the past month:
  Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
  due to the time sensitive nature of landing this and the need to
  backport it. Huge thanks to everyone who helped out here, and
  everyone at Intel who helped out in discussions about how to craft
  this. Also, credit goes to Paul Turner (at Google, but not an LLVM
  contributor) for much of the underlying retpoline design.

  Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

  Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

  Differential Revision: https://reviews.llvm.org/D41723

MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-02-02 22:28:12 +00:00
Dimitry Andric
842d113b5c Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-02-01 21:41:15 +00:00
Marius Strobl
c2a2eeff5c Account for the fact that jemalloc 5.0.0 dropped STATIC_PAGE_SHIFT
in favor for using LG_PAGE directly and, thus, for the fact that
host and target don't necessarily use pages of the same sizes.

Approved by:	jasone
2018-01-31 21:56:23 +00:00
John Baldwin
68e709cb29 Update limits on makecontext() arguments in the setcontext_link test.
sparc64 and riscv do not support 10 arguments, but MIPS now does.
While here, combine clauses for architectures that support the same
number of arguments to reduce duplication.

Sponsored by:	DARPA / AFRL
2018-01-31 18:03:40 +00:00
Ed Maste
e5c2ece714 Pull in r322131 from upstream llvm trunk (by Rafael Espíndola):
Use a MCExpr for the size of MCFillFragment.

  This allows the size to be found during ralaxation. This fixes
  [LLVM] pr35858.

Requested by:	royger
2018-01-30 16:43:20 +00:00
Ed Maste
88e56272f9 Pull in r322123 from upstream llvm trunk (by Rafael Espíndola):
Don't create MCFillFragment directly.

  Instead use higher level APIs that take care of most bookkeeping.
2018-01-30 16:42:08 +00:00
Ed Maste
00da656e30 Pull in r322108 from upstream llvm trunk (by Rafael Espíndola):
Make one of the emitFill methods non virtual. NFC.

  This is just preparatory work to fix [LLVM] PR35858.
2018-01-30 16:41:38 +00:00
Kyle Evans
acfa114e53 Remove t_grep:mmap_eof_not_eol test
The test was marked as an expected failure in r320414 after r319971's import
of a newer jemalloc removed an essential feature (opt.redzone) for
reproducing the behavior it was testing. Since then, no way has been found
or demonstrated to reliably test the behavior, so remove the test.

PR:		220309
2018-01-29 18:50:45 +00:00
Ed Maste
54a6825c80 lld: Put the header in the first PT_LOAD even if that PT_LOAD has a LMAExpr
The root problem is that we were creating a PT_LOAD just for the header.
That was technically valid, but inconvenient: we should not be making
the ELF discontinuous.

The solution is to allow a section with LMAExpr to be added to a PT_LOAD
if that PT_LOAD doesn't already have a LMAExpr.

LLVM PR:	36017
Obtained from:	LLVM r323625 by Rafael Espindola
2018-01-29 13:55:50 +00:00
Ed Maste
1da0355521 lld: Move LMAOffset from the OutputSection to the PhdrEntry. NFC.
If two sections are in the same PT_LOAD, their relatives offsets,
virtual address and physical addresses are all the same.

[Rafael] initially wanted to have a single global LMAOffset, on the
assumption that every ELF file was in practiced loaded contiguously in
both physical and virtual memory.

Unfortunately that is not the case. The linux kernel has:

  LOAD           0x200000 0xffffffff81000000 0x0000000001000000 0xced000 0xced000 R E 0x200000
  LOAD           0x1000000 0xffffffff81e00000 0x0000000001e00000 0x15f000 0x15f000 RW  0x200000
  LOAD           0x1200000 0x0000000000000000 0x0000000001f5f000 0x01b198 0x01b198 RW  0x200000
  LOAD           0x137b000 0xffffffff81f7b000 0x0000000001f7b000 0x116000 0x1ec000 RWE 0x200000

The delta for all but the third PT_LOAD is the same:
0xffffffff80000000. [Rafael] thinks the 3rd one is a hack for implementing
per cpu data, but we can't break that.

Obtained from:	LLVM r323456 by Rafael Espindola
2018-01-29 13:54:51 +00:00
Ed Maste
2b8c81f1b9 lld: Improve LMARegion handling.
This fixes the crash reported at [LLVM] PR36083.

The issue is that we were trying to put all the sections in the same
PT_LOAD and crashing trying to write past the end of the file.

This also adds accounting for used space in LMARegion, without it all
3 PT_LOADs would have the same physical address.

Obtained from:	LLVM r323449 by Rafael Espindola
2018-01-29 13:52:42 +00:00
Ed Maste
5a2ea37829 lld: Simplify. NFC.
Obtained from:	LLVM r323440 by Rafael Espindola
2018-01-29 13:51:13 +00:00
Ed Maste
6fcb8605ef lld: Remove MemRegionOffset. NFC.
We can just use a member variable in MemoryRegion.

Obtained from:	LLVM r323399 by Rafael Espindola
2018-01-29 13:50:28 +00:00
Ed Maste
70bad66509 lld: Only lookup LMARegion once. NFC.
This is similar to how we handle MemRegion.

Obtained from:	LLVM r323396 by Rafael Espindola
2018-01-29 13:49:10 +00:00
Ed Maste
032c24abe6 lld: Use lookup instead of find. NFC, just simpler.
Obtained from:	LLVM r323395 by Rafael Espindola
2018-01-29 13:48:15 +00:00
Pedro F. Giffuni
d54cfbd18e ftp(1): Use closefrom() instead of individual close()s.
Use closefrom(3) instead of manually closing all file descriptors
between 3 and 19.

Obtained from:	OpenBSD (CVS 1.80)
2018-01-29 01:05:57 +00:00
Dimitry Andric
48d95fd235 Pull in r322245 from upstream clang trunk (by Craig Topper):
[X86] Make -mavx512f imply -mfma and -mf16c in the frontend like it
  does in the backend.

  Similarly, make -mno-fma and -mno-f16c imply -mno-avx512f.

  Withou this  "-mno-sse -mavx512f" ends up with avx512f being enabled
  in the frontend but disabled in the backend.

Reported by:	pawel
PR:		225488
2018-01-28 16:10:40 +00:00
Pedro F. Giffuni
a645f2a50a Revert r328492:
"Fix gcc80 -Wsizeof-pointer-memaccess warning."

The warning is bogus: GCC8 only looks at the size of the destination.
We shouldn't be fixing imaginary problems, so perhaps its better to deal
with this later on by disabling such warnings.

Pointed out by:	ed, bde
2018-01-28 03:16:54 +00:00
Pedro F. Giffuni
e28c47b570 Fix gcc80 -Wsizeof-pointer-memaccess warning.
Obtained from:	DragonFlyBSD (git 56267d362d5769c8df07bf26d5e322610e0d24b4)
2018-01-27 22:16:19 +00:00
Michael Tuexen
51eff8efd9 When using SCTP for sending probe packets, use INIT chunks for payloads
larger than or equal to 32 bytes. For smaller probe packets, keep using
SHUTDOWN-ACK chunks, possibly bundled with a PAD chunk.
Packets with INIT chunks more likely pass through firewalls. Therefore,
use them when possible.

MFC after:	1 week
2018-01-27 19:23:42 +00:00
Warner Losh
919cf86c87 Gross hack to omit printing hex floating point when the lua number
type is int64. While lua is setup for the representation, it's not
setup to properly print the numbers as ints. This is the least-gross
way around that, and won't affect the bootloader where we do this.
2018-01-26 17:56:20 +00:00
Warner Losh
18dd077da6 Preserve the original luaconf.h in a convenient place. Clients will
almost certainly need to override this, so reinforce that. If that's
not hte case, clients can always do a #include luaconf.h.dist.
2018-01-26 17:24:25 +00:00
Dimitry Andric
042b1c2ef5 Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after:	3 months
X-MFC-With:	r327952
PR:		224669
2018-01-24 22:35:00 +00:00
Martin Matuska
a2a3407c7e MFV r328323,328324:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #893: delete dead ppmd7 alloc callbacks
  PR #904: Fix archive freeing bug in bsdcat
  PR #961: Fix ZIP format names
  PR #962: Don't modify attributes for existing directories
           when ARCHIVE_EXTRACT_NO_OVERWRITE is set
  PR #964: Fix -Werror=implicit-fallthrough= for GCC 7
  PR #970: zip: Allow backslash as path separator

MFC after:	1 week
2018-01-24 14:24:17 +00:00
Philip Paeps
afb91be3c9 Import tzdata 2018c
Changes: https://github.com/eggert/tz/blob/2018c/NEWS

MFC after:	3 days
2018-01-24 06:48:42 +00:00
Ed Maste
da1eeb70d3 lld: Don't mark a shared library as needed because of a lazy symbol.
Obtained from:	LLVM r323221 by Rafael Espíndola
2018-01-23 17:54:39 +00:00
Alan Somers
76f9d2759b mlock(2): correct documentation for error conditions.
The man page is years out of date regarding errors. Our implementation _does_
allow unaligned addresses, and it _does_not_ check for negative lengths,
because the length is unsigned. It checks for overflow instead.

Update the tests accordingly.

Reviewed by:	bcr
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13826
2018-01-22 21:45:54 +00:00
Andrey V. Elsukov
7e03e18104 Rename "index" variable to "idx" since gcc complains that it shadows
index(3) function declaration.

Reported by:	lwhsu
MFC after:	2 weeks
2018-01-19 20:33:47 +00:00
Andrey V. Elsukov
f3afd27f5f Add to bsnmpd(1) ability to specify multiple community strings with
different access rights.

By default there are two community strings with index 1 and 2, one for
read-only access and second for read-write access:

  begemotSnmpdCommunityString.0.1 = $(read)
  begemotSnmpdCommunityString.0.2 = $(write)

Now it is possible to define additional community strings using different
indexes:

  begemotSnmpdCommunityString.0.3 = "SomeString1"
  begemotSnmpdCommunityPermission.0.3 = 1
  begemotSnmpdCommunityString.0.4 = "SomeString2"
  begemotSnmpdCommunityPermission.0.4 = 2
  begemotSnmpdCommunityString.0.5 = "SomeString3"
  begemotSnmpdCommunityString.0.6 = "SomeString4"

New attribute begemotSnmpdCommunityPermission can be used to specify access
rights: 1 means "read-only" access, 2 means "read-write" access. If
attribute is not specified for some index this means "read-only" rights.

Community strings must be unique, i.e. must not be the same for different
indexes.

Obtained from:		Yandex LLC
MFC after:		2 weeks
Sponsored by:		Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D13785
2018-01-19 08:48:14 +00:00
Dimitry Andric
024469e429 Pull in r322106 from upstream llvm trunk (by Alexey Bataev):
[COST]Fix PR35865: Fix cost model evaluation for shuffle on X86.

  Summary:
  If the vector type is transformed to non-vector single type, the
  compile may crash trying to get vector information about non-vector
  type.

  Reviewers: RKSimon, spatel, mkuper, hfinkel

  Subscribers: llvm-commits

  Differential Revision: https://reviews.llvm.org/D41862

This should fix "Not a vector MVT!" errors when building the
games/dhewm3 port.

Reported by:	jbeich
PR:		225271
2018-01-18 21:46:09 +00:00
Dimitry Andric
6bee06efd1 Pull in r322016 from upstream llvm trunk (by Sanjay Patel):
[ValueTracking] remove overzealous assert

  The test is derived from a failing fuzz test:
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5008

  Credit to @rksimon for pointing out the problem.

This should fix "Bad flavor while matching min/max" errors when building
the graphics/libsixel and science/kst2 ports.

Reported by:	jbeich
PR:		225268, 225269
2018-01-18 21:44:07 +00:00
Ed Maste
62de8f4add lld: Fix incorrect physical address on self-referencing AT command.
When a section placement (AT) command references the section itself,
the physical address of the section in the ELF header was calculated
incorrectly due to alignment happening right after the location
pointer's value was captured.

The problem was diagnosed and the first version of the patch written
by Erick Reyes.

Obtained from:	LLVM r322421 by Rafael Espindola
2018-01-18 21:39:59 +00:00
Ed Maste
cc877d7c33 lld: Handle parsing AT(ADDR(.foo-bar)).
The problem we had with it is that anything inside an AT is an
expression, so we failed to parse the section name because of the - in
it.

Requested by:	royger
Obtained from:	LLVM r322801 by Rafael Espindola
2018-01-18 21:39:19 +00:00
Ed Maste
d3f08be7dc lld: Fix for ld.lld does not accept "AT" syntax for declaring LMA region
AT> lma_region expression allows to specify the memory region
for section load address.

Should fix [upstream LLVM] PR35684.

LLVM review: https://reviews.llvm.org/D41397

Obtained from:	LLVM r322359 by George Rimar
2018-01-18 21:38:21 +00:00
Dimitry Andric
d23c4359df Pull in r322623 from upstream llvm trunk (by Andrew V. Tischenko):
Allow usage of X86-prefixes as separate instrs.
  Differential Revision: https://reviews.llvm.org/D42102

This should fix parse errors when x86 prefixes (such as 'lock' and
'rep') are followed by various non-mnemonic tokens, e.g. comments, .byte
directives and labels.

PR:		224669,225054
2018-01-17 17:11:55 +00:00
Philip Paeps
f2fcff28d0 Import tzdata 2018a
Changes: https://github.com/eggert/tz/blob/2018a/NEWS

MFC after:	3 days
2018-01-16 18:36:25 +00:00
Dimitry Andric
a7264ff541 Pull in r322473 from upstream llvm trunk (by Andrei Elovikov):
[LV] Don't call recordVectorLoopValueForInductionCast for
  newly-created IV from a trunc.

  Summary:
  This method is supposed to be called for IVs that have casts in their
  use-def chains that are completely ignored after vectorization under
  PSE. However, for truncates of such IVs the same InductionDescriptor
  is used during creation/widening of both original IV based on PHINode
  and new IV based on TruncInst.

  This leads to unintended second call to
  recordVectorLoopValueForInductionCast with a VectorLoopVal set to the
  newly created IV for a trunc and causes an assert due to attempt to
  store new information for already existing entry in the map. This is
  wrong and should not be done.

  Fixes PR35773.

  Reviewers: dorit, Ayal, mssimpso

  Reviewed By: dorit

  Subscribers: RKSimon, dim, dcaballe, hsaito, llvm-commits, hiraditya

  Differential Revision: https://reviews.llvm.org/D41913

This should fix "Vector value already set for part" assertions when
building the net/iodine and sysutils/daa2iso ports.

Reported by:	jbeich
PR:		224867,224868
2018-01-15 18:20:15 +00:00
Dimitry Andric
72bfb31a82 Merge ^/head r327886 through r327930. 2018-01-13 17:52:55 +00:00
Dimitry Andric
55f46b3c87 Pull in r314499 from upstream clang trunk (by Daniel Marjamäki):
[Sema] Suppress warnings for C's zero initializer

  Patch by S. Gilles!

  Differential Revision: https://reviews.llvm.org/D28148

Pull in r314838 from upstream clang trunk (by Richard Smith):

  Suppress -Wmissing-braces warning when aggregate-initializing a
  struct with a single field that is itself an aggregate.

  In C++, such initialization of std::array<T, N> types is guaranteed
  to work by the standard, is completely idiomatic, and the "suggested"
  alternative from Clang was technically invalid.

Together, these suppress unneeded "suggest braces around initialization
of subobject" warnings for C++11 initializer lists.

MFC after:	3 days
2018-01-13 17:47:34 +00:00
Ed Maste
982fabe12e Revert r280909 "unwind-d2 build workaround for arm64"
We no longer try to build unwind-dw2.c on arm64 so no need for this
workaround.

Sponsored by:	The FreeBSD Foundation
2018-01-12 20:03:24 +00:00
Dimitry Andric
c79126f2e4 Merge ^/head r327624 through r327885. 2018-01-12 18:23:35 +00:00
Dimitry Andric
782f2e69ab Pull in r321994 from upstream llvm trunk (by Alexey Bataev):
[SLP] Fix PR35777: Incorrect handling of aggregate values.

  Summary:
  Fixes the bug with incorrect handling of InsertValue|InsertElement
  instrucions in SLP vectorizer. Currently, we may use incorrect
  ExtractElement instructions as the operands of the original
  InsertValue|InsertElement instructions.

  Reviewers: mkuper, hfinkel, RKSimon, spatel

  Subscribers: llvm-commits

  Differential Revision: https://reviews.llvm.org/D41767

This should fix "Invalid InsertValueInst operands!" errors when building
certain parts of editors/libreoffice.

Reported by:	jbeich
PR:		225086
2018-01-12 18:19:14 +00:00
Dimitry Andric
83ae25da0f Pull in r322264 from upstream lld trunk (by me):
Fix thread race between SectionPiece's OutputOff and Live members

  Summary:
  As reported in bug 35788, rL316280 reintroduces a race between two
  members of SectionPiece, which share the same 64 bit memory location.

  To fix the race, check the hash before checking the Live member, as
  suggested by Rafael.

  Reviewers: ruiu, rafael

  Reviewed By: ruiu

  Subscribers: smeenai, emaste, llvm-commits

  Differential Revision: https://reviews.llvm.org/D41884
2018-01-12 18:16:51 +00:00
Dimitry Andric
76401e35e3 Pull in r316581 from upstream llvm trunk (by John Baldwin):
Don't try to use a non-existent header on FreeBSD/mips.

  Reviewers: dim

  Differential Revision: https://reviews.llvm.org/D38807

Requested by:	jhb
MFC after:	3 days
2018-01-11 21:12:23 +00:00
Alan Somers
324efdfba2 Add Pull Request to the Subversion commit template
Reviewed by:	emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13178
2018-01-09 21:02:39 +00:00
Dimitry Andric
66f8bb86f8 Pull in r322056 from upstream llvm trunk (by Serguei Katkov):
[CGP] Fix Complex addressing mode for offset

  If the offset is differ in two addressing mode we can continue only
  if ScaleReg is not set due to we will use it as merge of different
  offsets.

  It should fix PR35799 and PR35805.

  Reviewers: john.brawn, reames
  Reviewed By: reames
  Subscribers: llvm-commits
  Differential Revision: https://reviews.llvm.org/D41227

This should fix "ScaledReg == nullptr" assertions when building the
graphics/xpx, mail/alpine and editors/pico-alpine ports.

Reported by:	jbeich
PR:		224866, 224995
2018-01-09 17:41:34 +00:00
Dimitry Andric
18a7633888 Pull in r322041 from upstream lld trunk (by Rui Ueyama):
Do not use parallelForEach to call maybeCompress().

  Currently LLVM's paralellForEach has a problem with reentracy.
  That caused https://bugs.llvm.org/show_bug.cgi?id=35788 (lld somtimes
  hangs while linking Ruby 2.4) because maybeCompress calls writeTo
  which uses paralellForEach.

  This patch is to avoid using paralellForEach to call maybeCompress to
  workaround the issue.

This should fix potential hangs when linking parts of ruby24.
2018-01-09 17:38:43 +00:00
Dimitry Andric
53743bd4bb Pull in r321986 from upstream lld trunk (by James Henderson):
[ELF] Compress debug sections after assignAddresses and support
  custom layout

  Previously, in r320472, I moved the calculation of section offsets
  and sizes for compressed debug sections into maybeCompress, which
  happens before assignAddresses, so that the compression had the
  required information. However, I failed to take account of
  relocations that patch such sections. This had two effects:

  1. A race condition existed when a debug section referred to a
     different debug section (see PR35788).
  2. References to symbols in non-debug sections would be patched
     incorrectly.  This is because the addresses of such symbols are not
     calculated until after assignAddresses (this was a partial
     regression caused by r320472, but they could still have been
     broken before, in the event that a custom layout was used in a
     linker script).

  assignAddresses does not need to know about the output section size
  of non-allocatable sections, because they do not affect the value of
  Dot. This means that there is no longer a reason not to support
  custom layout of compressed debug sections, as far as I'm aware.
  These two points allow for delaying when maybeCompress can be called,
  removing the need for the loop I previously added to calculate the
  section size, and therefore the race condition. Furthermore, by
  delaying, we fix the issues of relocations getting incorrect symbol
  values, because they have now all been finalized.

This should fix thread race conditions when linking parts of ruby24.
2018-01-09 17:37:09 +00:00
Dimitry Andric
687571a78b Pull in r321963 from upstream libc++ trunk (by me):
Add pre-C++11 is_constructible wrappers for 3 arguments

  Summary:
  After rL319736 for D28253 (which fixes PR28929), gcc cannot compile
  <memory> anymore in pre-C+11 modes, complaining:

  In file included from /usr/include/c++/v1/memory:648:0,
                   from test.cpp:1:
  /usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, _A2&)':
  /usr/include/c++/v1/memory:4365:5: error: wrong number of template arguments (4, should be at least 1)
       static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
       ^
  In file included from /usr/include/c++/v1/memory:649:0,
                   from test.cpp:1:
  /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
   struct _LIBCPP_TEMPLATE_VIS is_constructible
                               ^~~~~~~~~~~~~~~~
  In file included from /usr/include/c++/v1/memory:648:0,
                   from test.cpp:1:
  /usr/include/c++/v1/memory:4365:5: error: template argument 1 is invalid
       static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
       ^
  /usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const _Alloc&, _A0&, _A1&, _A2&)':
  /usr/include/c++/v1/memory:4444:5: error: wrong number of template arguments (4, should be at least 1)
       static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
       ^
  In file included from /usr/include/c++/v1/memory:649:0,
                   from test.cpp:1:
  /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
   struct _LIBCPP_TEMPLATE_VIS is_constructible
                               ^~~~~~~~~~~~~~~~
  In file included from /usr/include/c++/v1/memory:648:0,
                   from test.cpp:1:
  /usr/include/c++/v1/memory:4444:5: error: template argument 1 is invalid
       static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
       ^

  This is also reported in https://bugs.freebsd.org/224946 (FreeBSD is
  apparently one of the very few projects that regularly builds
  programs against libc++ with gcc).

  The reason is that the static assertions are invoking
  is_constructible with three arguments, while gcc does not have the
  built-in is_constructible feature, and the pre-C++11 is_constructible
  wrappers in <type_traits> only provide up to two arguments.

  I have added additional wrappers for three arguments, modified the
  is_constructible entry point to take three arguments instead, and
  added a simple test to is_constructible.pass.cpp.

  Reviewers: EricWF, mclow.lists

  Reviewed By: EricWF

  Subscribers: krytarowski, cfe-commits, emaste

  Differential Revision: https://reviews.llvm.org/D41805

This should allow gcc to compile the libc++ 6.0.0 <memory> header
without problems, in pre-C++11 mode.

Reported by:    jbeich
PR:             224946
2018-01-07 18:33:19 +00:00
Dimitry Andric
30785c0e2b Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.
2018-01-06 23:44:14 +00:00
Dimitry Andric
4b49587c3d Merge ^/head r327341 through r327623. 2018-01-06 16:13:17 +00:00
Dimitry Andric
a1ba34d4a7 Tentatively apply https://reviews.llvm.org/D41635:
We normally want to ignore SHT_NOBITS sections when computing
  offsets. The sh_offset of section itself seems to be irrelevant and

  * If the section is in the middle of a PT_LOAD, it will make no
    difference on the computed offset of the followup section.
  * If it is in the end of a PT_LOAD, we want to avoid its alignment
    changing the offset of the followup sections.

  The issue is if it is at the start of the PT_LOAD. In that case we do
  have to align it so that the following sections have congruent
  address and offset module the page size. We were not handling this
  case.

  This should fix freebsd kernel link.

In particular, this fixes ctfmerge and/or objcopy throwing "Layout
constraint violation" errors when processing an lld-linked kernel.
2018-01-06 13:19:36 +00:00
Ed Maste
aadb68849f elfcopy: copy raw (untranslated) contents to binary output
Previously elfcopy used elf_getdata to obtain data from ELF sections
being copied to binary output, but elf_getdata returns data that has
been translated - that is, data is in host byte order. When the host and
target differ in endianness (e.g., converting a big-endian MIPS ELF
object to binary on an x86 host) this resulted in byte-swapped data in
certain sections such as .dynamic.

Instead use elf_rawdata to keep data in the original, target endianness.

Reported by:	Hiroki Mori <yamori83@yahoo.co.jp>, Bill Yuan
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-01-02 14:07:55 +00:00
Dimitry Andric
4fc74049d2 Merge ^/head r327169 through r327340. 2017-12-29 12:51:26 +00:00
Dimitry Andric
fe4fed2e4d Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.
2017-12-29 00:56:15 +00:00
Ed Maste
7003cfb386 readelf: report byte size for DT_PREINIT_ARRAYSZ
Sponsored by:	The FreeBSD Foundation
2017-12-26 18:10:34 +00:00
Dimitry Andric
a6c6e8627e Merge ^/head r327150 through r327164. 2017-12-24 16:53:55 +00:00
Dimitry Andric
34f4d02c2f 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
2017-12-24 16:51:59 +00:00
Dimitry Andric
0e56f9238c For our lldb customizations, instead of commenting out lines, use #ifdef
LLDB_ENABLE_ALL / #endif preprocess directives instead, so our diffs
against upstream only consist of added lines.
2017-12-24 13:39:32 +00:00
Dimitry Andric
39f349c2ce Merge libc++ trunk r321414 to contrib/libc++. 2017-12-24 01:16:28 +00:00
Dimitry Andric
5d5f867805 Merge compiler-rt trunk r321414 to contrib/compiler-rt. 2017-12-24 01:15:12 +00:00
Dimitry Andric
3863851369 Merge lldb trunk r321414 to contrib/llvm/tools/lldb. 2017-12-24 01:12:46 +00:00
Dimitry Andric
8ca4c80b1b Merge lld trunk r321414 to contrib/llvm/tools/lld. 2017-12-24 01:11:19 +00:00
Dimitry Andric
13ddaa8416 Merge clang trunk r321414 to contrib/llvm. 2017-12-24 01:08:34 +00:00
Dimitry Andric
da09e106ef Merge llvm trunk r321414 to contrib/llvm. 2017-12-24 01:04:58 +00:00
Dimitry Andric
b2c7081bd7 Merge libc++ trunk r321017 to contrib/libc++. 2017-12-20 19:16:11 +00:00
Dimitry Andric
8a51db9c42 Merge compiler-rt trunk r321017 to contrib/compiler-rt. 2017-12-20 19:12:15 +00:00
Dimitry Andric
acac075be8 Merge lldb trunk r321017 to contrib/llvm/tools/lldb. 2017-12-20 18:06:09 +00:00
Dimitry Andric
10dc89a5a7 Merge lld trunk r321017 to contrib/llvm/tools/lld. 2017-12-20 15:50:21 +00:00
Dimitry Andric
9a199699c2 Merge clang trunk r321017 to contrib/llvm/tools/clang. 2017-12-20 14:26:54 +00:00
Dimitry Andric
2cab237b5d Merge llvm trunk r321017 to contrib/llvm. 2017-12-20 14:16:56 +00:00
Ed Maste
a5d5fd9ffd lld: Don't write preemptible symbol values to the .got.
It is not necessary and matches what bfd and gold do.

This was a regression from [LLVM] r315658.

Obtained from:	LLVM r321023 by Rafael Espíndola
2017-12-19 03:15:20 +00:00
Dimitry Andric
5bf0d7ad74 Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.1 release (upstream r320880).

Relnotes:	yes
MFC after:	2 weeks
2017-12-16 18:06:30 +00:00
Ed Maste
e10e2b23bf lld: Slightly simplify code and add comment.
Cherry-pick lld r315658 by Rui Ueyama:
    This is not a mechanical transformation. Even though I believe this
    patch is correct, I'm not 100% sure if lld with this patch behaves
    exactly the same way as before on all edge cases. At least all tests
    still pass.

    I'm submitting this patch because it took almost a day to understand
    this function, and I don't want to lose it.

This fixes jemalloc assertion failures observed at startup with i386
binaries and an lld-linked libc.so.

Reviewed by:	dim
Obtained from:	LLVM r315658
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13503
2017-12-16 14:26:11 +00:00
Dimitry Andric
e3e18337bf Pull in r320755 from upstream clang trunk (by me):
Don't trigger -Wuser-defined-literals for system headers

  Summary:
  In D41064, I proposed adding `#pragma clang diagnostic ignored
  "-Wuser-defined-literals"` to some of libc++'s headers, since these
  warnings are now triggered by clang's new `-std=gnu++14` default:

  $ cat test.cpp
  #include <string>

  $ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
  In file included from test.cpp:1:
  In file included from /usr/include/c++/v1/string:470:
  /usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                              ^
  /usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
                                 ^
  /usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
                                  ^
  /usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
                                  ^
  In file included from test.cpp:1:
  /usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char> operator "" s( const char *__str, size_t __len )
                         ^
  /usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                            ^
  /usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
                             ^
  /usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
                             ^
  8 warnings generated.

  Both @aaron.ballman and @mclow.lists felt that adding this workaround
  to the libc++ headers was the wrong way, and it should be fixed in
  clang instead.

  Here is a proposal to do just that.  I verified that this suppresses
  the warning, even when -Wsystem-headers is used, and that the warning
  is still emitted for a declaration outside of system headers.

  Reviewers: aaron.ballman, mclow.lists, rsmith

  Reviewed By: aaron.ballman

  Subscribers: mclow.lists, aaron.ballman, andrew, emaste, cfe-commits

  Differential Revision: https://reviews.llvm.org/D41080

This will allow to compile some of the libc++ headers in C++14 mode
(which is the default for gcc 6 and higher, and will be the default for
clang 6.0.0 and higher), with -Wsystem-headers and -Werror enabled.

Reported by:	andrew
MFC after:	3 days
2017-12-15 18:58:21 +00:00
Ed Maste
df1f0f9b90 lld: Simplify a boolean expression by De Morgan's laws.
Cherry-pick lld r315653 by Rui Ueyama:
    I don't really understand what exactly this expression means,
    but at least I can mechanically transform it.

Obtained from:	LLVM r315653
MFC after:	1 week
2017-12-15 18:56:12 +00:00
Dimitry Andric
f134051fcf Pull in r315334 from upstream lld trunk (by Rafael Espindola):
Don't create a dummy __tls_get_addr.

  We just don't need one with the current setup.

  We only error on undefined references that are used by some
  relocation.

  If we managed to relax all uses of __tls_get_addr, no relocation uses
  it and we don't produce an error.

  This is less code and fixes the case were we fail to relax. Before we
  would produce a broken output, but now we produce an error.

Pull in r320390 from upstream lld trunk (by Rafael Espindola):

  Create reserved symbols early so they can be versioned.

  This fixes pr35570.

  We were creating these symbols after parsing version scripts, so they
  could not be versioned.

  We cannot move the version script parsing later because we need it for
  lto.

  One option is to move both addReservedSymbols and
  createSyntheticSections earlier. The disadvantage is that some
  sections created by createSyntheticSections replace other input
  sections. For example, gdb index replaces .debug_gnu_pubnames, so it
  wants to run after gc sections so that it can set S->Live to false.

  What this patch does instead is to move just the ElfHeader creation
  early.

Pull in r320412 from upstream lld trunk (by Rafael Espindola):

  Handle symbols pointing to output sections.

  Now that gc sections runs after linker defined symbols are added it
  can see symbols that point to an OutputSection.

  Should fix a bot failure.

Pull in r320431 from upstream lld trunk (by Peter Collingbourne):

  ELF: Do not follow relocation edges to output sections during GC.

  This fixes an assertion error introduced by r320390.

  Differential Revision: https://reviews.llvm.org/D41095

Together these fix handling of reserved symbols, in particular _end,
which is needed to make brk(2) and sbrk(2) work correctly.  This
unbreaks the emacs ports on amd64, and also appears to unbreak most of
world on i386.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D13466
2017-12-13 19:03:48 +00:00
Alan Somers
25b86f88e3 less(1): diff reduction vs upstream
No functional change.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-12-12 17:34:35 +00:00
Dimitry Andric
9ce629675f Pull in r320396 from upstream clang trunk (by Malcolm Parsons):
[Sema] Fix crash in unused-lambda-capture warning for VLAs

  Summary:
  Clang was crashing when diagnosing an unused-lambda-capture for a VLA
  because From.getVariable() is null for the capture of a VLA bound.
  Warning about the VLA bound capture is not helpful, so only warn for
  the VLA itself.

  Fixes: PR35555

  Reviewers: aaron.ballman, dim, rsmith

  Reviewed By: aaron.ballman, dim

  Subscribers: cfe-commits

  Differential Revision: https://reviews.llvm.org/D41016

This fixes a segfault when building recent audio/zynaddsubfx port
versions.

Reported by:	hps
MFC after:	3 days
2017-12-11 20:04:40 +00:00
Konstantin Belousov
b258727e79 ofed: Define barriers for mips and arm.
I used the strongest barriers available on the architectures, so if
the future analysis show that it is excessive, the barriers could be
relaxed. Still, it is unlikely that it is meaningful to run IB on 32bit
ARM or current MIPS machines, so the change is to make WITH_OFED to pass
tinderbox.

Sponsored by:	Mellanox Technologies
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D13329
2017-12-11 11:59:45 +00:00
Konstantin Belousov
0521e6e192 ofed: Remove duplicated symbols from the version file.
ld.bfd accepts multiple listing of the same symbol in the version script.
lld is stricter and errors out.  Since arm64 and sometimes amd64 use lld,
we should correct this cosmetic issue.

Sponsored by:	Mellanox Technologies
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D13329
2017-12-11 11:57:46 +00:00
Michal Meloun
d65a63e3aa Relax too restrictive assert.
The problem has been reported to upstream and similar change will
be included in next jemalloc release.

Submitted by:	David Goldblatt <davidtgoldblatt@gmail.com>
MFC after: 	2 weeks
2017-12-10 09:17:21 +00:00
Michal Meloun
e7dad90fe5 Revert r326740. I committed wrong diff. 2017-12-10 09:15:37 +00:00
Michal Meloun
3ee2fe0199 Relax too restrictive assert.
The problem has been reported to upstream and similar change will
be included in next jemalloc release.

Submitted by:	David Goldblatt <davidtgoldblatt@gmail.com>
MFC after: 	2 weeks
2017-12-10 08:55:48 +00:00
Hans Petter Selasky
656371d7c1 Correctly define the unordered_map namespace in ofed/libibnetdisc .
This should fix ofed/libibnetdisc compilation with C-compilers
different from clang and GCC v4.2.1.

Submitted by:	kib
Sponsored by:	Mellanox Technologies
2017-12-08 21:01:09 +00:00
Baptiste Daroussin
b0b2d05fd0 Split body of mails not respecting RFC2822
For mails which has a body not respecting RFC2822 (which often happen with
crontabs) try to split by words finding the last space before 1000's character

If no spaces are found then consider the mail to be malformed anyway

PR:		208261
2017-12-06 22:08:35 +00:00
Stephen J. Kiernan
b32f189046 The function make_relative_prefix_1 does not properly free locally
allocated memory when it returns early.

Free the memory associated with the variables full_programe, bin_dirs,
prog_dirs, and prefix_dirs when the function returns early.

Submitted by:	Tom Rix <trix@juniper.net>
Reviewed by:	jhibbits, emaste
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D9691
2017-12-06 21:18:45 +00:00
Ed Maste
0bff6a5af8 Update tcpdump to 4.9.2
It contains many fixes, including bounds checking, buffer overflows (in
SLIP and bittok2str_internal), buffer over-reads, and infinite loops.

One other notable change:
  Do not use getprotobynumber() for protocol name resolution.
  Do not do any protocol name resolution if -n is specified.

Submitted by:	gordon
Reviewed by:	delphij, emaste, glebius
MFC after:	1 week
Relnotes:	Yes
Security:	CVE-2017-11108, CVE-2017-11541, CVE-2017-11542
Security:	CVE-2017-11543, CVE-2017-12893, CVE-2017-12894
Security:	CVE-2017-12895, CVE-2017-12896, CVE-2017-12897
Security:	CVE-2017-12898, CVE-2017-12899, CVE-2017-12900
Security:	CVE-2017-12901, CVE-2017-12902, CVE-2017-12985
Security:	CVE-2017-12986, CVE-2017-12987, CVE-2017-12988
Security:	CVE-2017-12989, CVE-2017-12990, CVE-2017-12991
Security:	CVE-2017-12992, CVE-2017-12993, CVE-2017-12994
Security:	CVE-2017-12995, CVE-2017-12996, CVE-2017-12997
Security:	CVE-2017-12998, CVE-2017-12999, CVE-2017-13000
Security:	CVE-2017-13001, CVE-2017-13002, CVE-2017-13003
Security:	CVE-2017-13004, CVE-2017-13005, CVE-2017-13006
Security:	CVE-2017-13007, CVE-2017-13008, CVE-2017-13009
Security:	CVE-2017-13010, CVE-2017-13011, CVE-2017-13012
Security:	CVE-2017-13013, CVE-2017-13014, CVE-2017-13015
Security:	CVE-2017-13016, CVE-2017-13017, CVE-2017-13018
Security:	CVE-2017-13019, CVE-2017-13020, CVE-2017-13021
Security:	CVE-2017-13022, CVE-2017-13023, CVE-2017-13024
Security:	CVE-2017-13025, CVE-2017-13026, CVE-2017-13027
Security:	CVE-2017-13028, CVE-2017-13029, CVE-2017-13030
Security:	CVE-2017-13031, CVE-2017-13032, CVE-2017-13033
Security:	CVE-2017-13034, CVE-2017-13035, CVE-2017-13036
Security:	CVE-2017-13037, CVE-2017-13038, CVE-2017-13039
Security:	CVE-2017-13040, CVE-2017-13041, CVE-2017-13042
Security:	CVE-2017-13043, CVE-2017-13044, CVE-2017-13045
Security:	CVE-2017-13046, CVE-2017-13047, CVE-2017-13048
Security:	CVE-2017-13049, CVE-2017-13050, CVE-2017-13051
Security:	CVE-2017-13052, CVE-2017-13053, CVE-2017-13054
Security:	CVE-2017-13055, CVE-2017-13687, CVE-2017-13688
Security:	CVE-2017-13689, CVE-2017-13690, CVE-2017-13725
Differential Revision:	https://reviews.freebsd.org/D12404
2017-12-06 02:21:11 +00:00
Jilles Tjoelker
965f7130a9 mdoc(7): Update .Dd for previous commit 2017-12-05 23:06:15 +00:00
Jilles Tjoelker
6c144446e9 mdocml: Add IEEE Std 1003.1-2008, 2016 edition
Also document IEEE Std 1003.1-2008, 2013 edition in mdoc(7) (as well as the
2016 edition).

Submitted by:	Yuri Pankov
Reviewed by:	bjk
Differential Revision:	https://reviews.freebsd.org/D13349
2017-12-05 23:00:41 +00:00
Warner Losh
c87d5a5826 Since this is contrib code, create an upstreamable version of my
change. Now on FreeBSD and NetBSD if _STANDALONE is defined, we
include the kernel version with alloances for the quirky differences
between the two.

Sponsored by: Netflix
2017-12-05 22:24:20 +00:00
Warner Losh
52634ec581 This isn't NetBSD specific code. Include these for any kernel /
standalone use. Tweak for FreeBSD's quirky limits.h stuff.

Sponsored by: Netflix
2017-12-05 21:38:10 +00:00
Hans Petter Selasky
be28698cf2 Correctly prefix the infiniband include directory for buildworld. This fixes
the OFED buildworld target, WITH_OFED=YES, when the include files are not
already installed locally, but only in the temporary object directory.

Found by:	kib
Sponsored by:	Mellanox Technologies
2017-12-05 08:25:17 +00:00
Ed Maste
a6aca65caf lld: make -v behave similarly to GNU ld.bfd
Previously, lld exited with an error status if the only option given to
the command was -v. GNU linkers gracefully exit in that case. This patch
makes lld behave like GNU.

Note that even with this patch, lld's -v and --version options behave
slightly differently than GNU linkers' counterparts. For example,
if you run ld.bfd -v -v, the version string is printed out twice.
But that is an edge case that I don't think we need to take care of.

Fixes https://bugs.llvm.org/show_bug.cgi?id=31582

Obtained from:	LLVM r319717
MFC after:	1 week
2017-12-05 01:47:41 +00:00
Baptiste Daroussin
2c7292e5b4 Properly name the 2013 edition
Reported by:	ed
2017-12-04 09:58:38 +00:00
Baptiste Daroussin
ec5c474feb Add Posix 2013 référence for manpages
PR:		223930
Reported by:	Mateusz Piotrowski <mpp302@gmail.com>
MFC after:	2 days
2017-12-04 09:48:55 +00:00
Andrey V. Elsukov
49ba44e765 Fix format string warning with enabled DEBUGGING.
MFC after:	1 week
2017-12-04 09:17:28 +00:00
Dimitry Andric
d4419f6fa8 Upgrade our copies of clang, llvm, lldb and libc++ to r319231 from the
upstream release_50 branch.  This corresponds to 5.0.1 rc2.

MFC after:	2 weeks
2017-12-03 12:14:34 +00:00
Warner Losh
8e3e3a7ae8 Import lua 5.3.4 to contrib 2017-11-29 00:46:36 +00:00
Brooks Davis
ff88ef4183 Update vis(3) the latest from NetBSD.
This adds VIS_DQ for compatiblity with OpenBSD.

Correct by an off-by-one error and a read buffer overflow detected using
asan.

MFC after:	1 day
2017-11-28 01:35:28 +00:00
Hans Petter Selasky
8a53e1340f Merge ^/head r326132 through r326161. 2017-11-24 12:13:27 +00:00
Hans Petter Selasky
e833305789 Simplify the build dependencies when building the OFED libraries.
Suggested by:	bdrewery@
Sponsored by:	Mellanox Technologies
2017-11-24 09:01:08 +00:00
Ed Maste
b452493a3d bfd: avoid crash on corrupt binaries
From binutils commits 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 and
7e1e19887abd24aeb15066b141cdff5541e0ec8e, made available under GPLv2
by Nick Clifton.

PR:		198824
MFC after:	1 week
Security:	CVE-2014-8501
Security:	CVE-2014-8502
2017-11-23 16:04:52 +00:00
Ed Maste
bd036e101c bfd: fix segfault in the ihex parser on malformed ihex file
From binutils commit 0102ea8cec5fc509bba6c91df61b7ce23a799d32, made
available under GPLv2 by Nick Clifton.

PR:		198824
MFC after:	1 week
Security:	CVE-2014-8503
2017-11-23 14:30:41 +00:00
Hans Petter Selasky
82725ba9bf Merge ^/head r325999 through r326131. 2017-11-23 14:28:14 +00:00
Xin LI
b2ea244070 MFV r326007: less v529.
MFC after:	2 weeks
2017-11-20 08:52:33 +00:00
Hans Petter Selasky
d39ec9aea1 There is no need to depend on libthr.
Suggested by:	bdrewery@
Sponsored by:	Mellanox Technologies
2017-11-19 12:29:50 +00:00
Hans Petter Selasky
0b12d33c3c Fix compilation of libibnetdisc using in-base GCC v4.2.1.
Sponsored by:	Mellanox Technologies
2017-11-17 15:23:42 +00:00
Hans Petter Selasky
7093892ca0 Fix compilation for libsysdecode.
Don't install the ib_user_mad.h header file into user-space,
because it conflicts with umad.h from libibumad.h when building
libsysdecode.

Sponsored by:	Mellanox Technologies
2017-11-16 15:18:36 +00:00
Hans Petter Selasky
f04e941e25 Remove conflicting uint definition.
Already defined by sys/types.h

Sponsored by:	Mellanox Technologies
2017-11-16 15:16:53 +00:00