Commit Graph

8731 Commits

Author SHA1 Message Date
Brooks Davis
c697fb7f7c Add liblutok a lightweight C++ API for lua.
It is added an INTERNALLIB and not installed.  It will be used by kyua.

This is a preparatory commit for D24103.

Reviewed by:	emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA
2020-03-23 18:26:23 +00:00
Xin LI
a8675d927b MFV r359197: xz 5.2.5.
MFC after:	2 weeks
Relnotes:	yes
2020-03-22 01:27:38 +00:00
Ed Maste
e982f6f935 readelf: simplify Xen string note printing
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24140
2020-03-21 00:08:33 +00:00
Mark Johnston
c364ccf9ce libelftc: Fix a memory leak in cpp_demangle_read_type().
CID:		1305425
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:25:06 +00:00
Mark Johnston
d5e7add6b5 readelf: Fix another instance of the leak mentioned in r357542.
CID:		1292493
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:24:53 +00:00
Mark Johnston
c37c6b38b6 readelf: Avoid leaking ELF descriptors for archive entries.
CID:		1292494
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:24:40 +00:00
Mark Johnston
388586bcd8 libpe: Avoid a potential use-after-free in pe_update_symtab().
This function appears to be unused within FreeBSD and ELFToolChain.

CID:		1418982
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:24:23 +00:00
Mark Johnston
a9d65c5fae libdwarf: Make an out-pointer assignment unconditional.
There is no reason for diep to ever be NULL, since in that case we would
simply be leaking memory.

CID:		1418801
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:24:06 +00:00
Ed Maste
05ab65497e objcopy: add new sections also when there is no .shstrtab
Previously objcopy (elfcopy) --add-sections inserted new sections before
.shstrtab, but omitted them if there was no .shstrtab.

Now, after processing existing sections add new sections if they were
not yet added.

PR:		241437
Reported by:	arrowd
Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23571
2020-03-20 15:50:37 +00:00
Dimitry Andric
9ec406dc40 Merge commit 585a3cc31 from llvm git (by me):
Fix -Wdeprecated-copy-dtor and -Wdeprecated-dynamic-exception-spec
  warnings.

  Summary:
  The former are like:

  libcxx/include/typeinfo:322:11: warning: definition of implicit copy
  constructor for 'bad_cast' is deprecated because it has a
  user-declared destructor [-Wdeprecated-copy-dtor]
    virtual ~bad_cast() _NOEXCEPT;
	    ^
  libcxx/include/typeinfo:344:11: note: in implicit copy constructor
  for 'std::bad_cast' first required here
      throw bad_cast();
	    ^

  Fix these by adding an explicitly defaulted copy constructor.

  The latter are like:

  libcxx/include/codecvt:105:37: warning: dynamic exception
  specifications are deprecated [-Wdeprecated-dynamic-exception-spec]
      virtual int do_encoding() const throw();
				      ^~~~~~~

  Fix these by using the _NOEXCEPT macro instead.

  Reviewers: EricWF, mclow.lists, ldionne, #libc

  Reviewed By: EricWF, #libc

  Subscribers: dexonsmith, libcxx-commits

  Tags: #libc

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

This is because we use -Wsystem-headers during buildworld, and the two
warnings above are now triggered by default with clang 10, preventing
most C++ code from compiling without NO_WERROR.

Requested by:	brooks
MFC after:	6 weeks
X-MFC-With:	358851
Differential Revision: https://reviews.freebsd.org/D24049
2020-03-18 20:50:30 +00:00
Dimitry Andric
e39dad62a8 Merge commit b8ebc11f0 from llvm git (by Sanjay Patel):
[EarlyCSE] avoid crashing when detecting min/max/abs patterns (PR41083)

  As discussed in PR41083:
  https://bugs.llvm.org/show_bug.cgi?id=41083
  ...we can assert/crash in EarlyCSE using the current hashing scheme
  and instructions with flags.

  ValueTracking's matchSelectPattern() may rely on overflow (nsw, etc)
  or other flags when detecting patterns such as min/max/abs composed
  of compare+select. But the value numbering / hashing mechanism used
  by EarlyCSE intersects those flags to allow more CSE.

  Several alternatives to solve this are discussed in the bug report.
  This patch avoids the issue by doing simple matching of min/max/abs
  patterns that never requires instruction flags. We give up some CSE
  power because of that, but that is not expected to result in much
  actual performance difference because InstCombine will canonicalize
  these patterns when possible. It even has this comment for abs/nabs:

    /// Canonicalize all these variants to 1 pattern.
    /// This makes CSE more likely.

  (And this patch adds PhaseOrdering tests to verify that the expected
  transforms are still happening in the standard optimization
  pipelines.

  I left this code to use ValueTracking's "flavor" enum values, so we
  don't have to change the callers' code. If we decide to go back to
  using the ValueTracking call (by changing the hashing algorithm
  instead), it should be obvious how to replace this chunk.

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

This fixes an assertion when building the math/gsl port on PowerPC64.

Requested by:	pkubja
MFC after:	6 weeks
X-MFC-With:	358851
2020-03-18 20:44:40 +00:00
Dimitry Andric
5a0c326f63 Merge commit 315f8a55f from llvm git (by Fangrui Song):
[ELF][PPC32] Don't report "relocation refers to a discarded section"
  for .got2

  Similar to D63182 [ELF][PPC64] Don't report "relocation refers to a
  discarded section" for .toc

  Reviewed By: Bdragon28

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

This is needed to fix compile errors when building for ppc32/lld10.

Requested by:	bdragon
MFC after:	6 weeks
X-MFC-With:	358851
Differential Revision: https://reviews.freebsd.org/D24110
2020-03-18 20:38:15 +00:00
Dimitry Andric
92c0d181e5 Merge commit 00925aadb from llvm git (by Fangrui Song):
[ELF][PPC32] Fix canonical PLTs when the order does not match the PLT order

  Reviewed By: Bdragon28

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

This is needed to fix miscompiled canonical PLTs on ppc32/lld10.

Requested by:	bdragon
MFC after:	6 weeks
X-MFC-With:	358851
Differential Revision: https://reviews.freebsd.org/D24109
2020-03-18 20:28:26 +00:00
Dimitry Andric
cd675bb60e Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.0-rc4-5-g52c365aa9ca.  The actual release should follow Real
Soon Now.

PR:             244251
MFC after:      6 weeks
2020-03-18 18:26:53 +00:00
Dimitry Andric
16b9056593 Merge ^/head r358731 through r358831. 2020-03-10 07:04:05 +00:00
Ed Maste
13f7dbe822 retire amd(8)
autofs was introduced with FreeBSD 10.1 and is the supported method for
automounting filesystems.  As of r296194 the amd man page claimed that it
is deprecated.  Remove it from base now; the sysutils/am-utils port is
still available if necessary.

Discussed with:	cy
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2020-03-09 20:46:43 +00:00
Dimitry Andric
2ac6b71f31 Merge ^/head r358712 through r358730. 2020-03-07 15:09:45 +00:00
Ed Maste
6c37d6032e readelf: print GNU Build-ID
Sponsored by:	The FreeBSD Foundation
2020-03-06 17:24:51 +00:00
Dimitry Andric
f7ed37c525 Merge ^/head r358678 through r358711. 2020-03-06 17:11:29 +00:00
Dimitry Andric
fc7efa1b6a Merge commit f75939599 from llvm git (by Erich Keane):
Reland r374450 with Richard Smith's comments and test fixed.

  The behavior from the original patch has changed, since we're no
  longer allowing LLVM to just ignore the alignment.  Instead, we're
  just assuming the maximum possible alignment.

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

  llvm-svn: 374562

This fixes 'Assertion failed: (Alignment != 0 && "Invalid Alignment"),
function CreateAlignmentAssumption', when building recent versions of
v8, which invoke __builtin_assume_aligned() with its alignment argument
set to 4GiB or more.

Clang will now report a warning, and show the maximum possible alignment
instead, e.g.:

huge-align.cpp:1:27: warning: requested alignment must be 536870912 bytes or smaller; maximum alignment assumed [-Wbuiltin-assume-aligned-alignment]
void *f(void *g) { return __builtin_assume_aligned(g, 4294967296); }
                          ^                           ~~~~~~~~~~

Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=43839
Reported by:	cem
MFC after:	3 days
2020-03-06 17:02:14 +00:00
Ed Maste
ff0f134bb1 readelf: decode and print Xen ELF note strings
Sponsored by:	The FreeBSD Foundation
2020-03-06 15:58:52 +00:00
Ed Maste
4d8a9faf17 readelf: add XEN_ELFNOTE_PHYS32_ENTRY note
See r336469 for details.

Sponsored by:	The FreeBSD Foundation
2020-03-06 15:26:15 +00:00
Ed Maste
2f7242ed33 libelf: rationalize error handling in ELF note conversion
Previously _libelf_cvt_NOTE_tom (to host) returned false if a note's
namesz + descsz exceeded the buffer size, while _libelf_cvt_NOTE_tof
(to file) silently truncated.  Return false in the latter case too.

Sponsored by:	The FreeBSD Foundation
2020-03-05 20:53:43 +00:00
Dimitry Andric
8c27c5541e Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
commit llvmorg-10.0.0-rc3-1-gc290cb61fdc), and bump versions.
2020-03-05 18:11:47 +00:00
Dimitry Andric
69660011c6 Revert r357259, after the merge from head which added linker scripts for
stand/i386 boot:

Revert upstream lld r371957 (git commit 06bb7dfbd) by Fangrui Song:

  [ELF] Map the ELF header at imageBase

  If there is no readonly section, we map:

  * The ELF header at imageBase+maxPageSize
  * Program headers at imageBase+maxPageSize+sizeof(Ehdr)
  * The first section .text at imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)

  Due to the interaction between Writer<ELFT>::fixSectionAlignments and
  LinkerScript::allocateHeaders,
  `alignDown(p_vaddr(R PT_LOAD)) = alignDown(p_vaddr(RX PT_LOAD))`.
  The RX PT_LOAD will override the R PT_LOAD at runtime, which is not ideal:

  ```
  // PHDR at 0x401034, should be 0x400034
    PHDR           0x000034 0x00401034 0x00401034 0x000a0 0x000a0 R   0x4
  // R PT_LOAD contains just Ehdr and program headers.
  // At 0x401000, should be 0x400000
    LOAD           0x000000 0x00401000 0x00401000 0x000d4 0x000d4 R   0x1000
    LOAD           0x0000d4 0x004010d4 0x004010d4 0x00001 0x00001 R E 0x1000
  ```

  * createPhdrs allocates the headers to the R PT_LOAD.
  * fixSectionAlignments assigns `imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)` (formula: `alignTo(dot, maxPageSize) + dot % config->maxPageSize`) to addrExpr of .text
  * allocateHeaders computes the minimum address among SHF_ALLOC sections, i.e. addr(.text)
  * allocateHeaders sets address of ELF header to `addr(.text)-sizeof(Ehdr)-sizeof(program headers) = imageBase+maxPageSize`

  The main observation is that when the SECTIONS command is not used, we
  don't have to call allocateHeaders. This requires an assumption that
  the presence of PT_PHDR and addresses of headers can be decided
  regardless of address information.

  This may seem natural because dot is not manipulated by a linker script.
  The other thing is that we have to drop the special rule for -T<section>
  in `getInitialDot`. If -Ttext is smaller than the image base, the headers
  will not be allocated with the old behavior (allocateHeaders is called)
  but always allocated with the new behavior.

  The behavior change is not a problem. Whether and where headers are
  allocated can vary among linkers, or ld.bfd across different versions
  (--enable-separate-code or not). It is thus advised to use a linker
  script with the PHDRS command to have a consistent behavior across
  linkers. If PT_PHDR is needed, an explicit --image-base can be a simpler
  alternative.

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

  llvm-svn: 371957
2020-03-05 18:09:19 +00:00
Dimitry Andric
e43d33d286 Merge ^/head r358466 through r358677. 2020-03-05 17:55:36 +00:00
Cy Schubert
2d4e511ca2 MFV r358616:
Update ntp-4.2.8p13 --> 4.2.8p14.

The advisory can be found at:
http://support.ntp.org/bin/view/Main/SecurityNotice#\
March_2020_ntp_4_2_8p14_NTP_Rele

No CVEs have been documented yet.

MFC after:	now
Security:	http://support.ntp.org/bin/view/Main/NtpBug3610
		http://support.ntp.org/bin/view/Main/NtpBug3596
		http://support.ntp.org/bin/view/Main/NtpBug3592
2020-03-04 21:45:12 +00:00
Ed Maste
89839cad79 readelf: simplify namesz / descsz checks
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-03-04 20:41:45 +00:00
Ed Maste
721ac29c0c readelf: check note namesz and descsz
Previously corrupt note namesz or descsz (perhaps caused by readelf's
current lack of endian support for notes) resulted in a crash.  Check
that namesz and descsz do not extend beyond the end of the buffer before
trying to access name and desc data.

Reported by:	jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-03-04 20:29:49 +00:00
Ed Maste
d06e23f9d9 Reserve WXNEEDED ELF feature control flag
This will be used to tag binaries that require W+X mappings, in advance
of the ability to prevent W^X in mmap/mprotect.

There is still some discussion about the flag's name, but the ABI won't
change even if the name does (as kib pointed out in the review).

Reviewed by:	csjp, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23909
2020-03-04 18:21:30 +00:00
Ed Maste
465454ebad Remove old contrib/libstdc++, unused since r358454
Sponsored by:	The FreeBSD Foundation
2020-03-02 14:04:09 +00:00
Martin Matuska
f55be4fc57 MFV r358511,r358532:
Sync libarchive with vendor.

Relevant vendor changes:
  Issue #1257: Add testcase for ZIPX files with LZMA_STREAM_END marker
  PR #1331: cpio.5: fix hard link description
  Issue #1335: archive_read.c: fix UBSan warning about undefined behavior
  Issue #1338: XAR reader: fix UBSan warning about undefined behavior
  Issue #1339: bsdcpio_test: fix datatype in from_hex()
  Issue #1341: Safe writes: delete temporary file if rename fails.
  Issue #1341: Safe writes: improve error handling

MFC after:	1 week
2020-03-02 08:44:58 +00:00
Ed Maste
8e7e7da5ec readelf: add PROTMAX_DISABLE and STKGAP_DISABLE
From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE).  Commited
upstream (in a slightly different form) as r3831.

Sponsored by:	The FreeBSD Foundation
2020-03-01 20:25:57 +00:00
Ed Maste
134b378392 retire in-tree GPL dtc devicetree compiler
Now that we no longer have GCC 4.2.1 in the tree and can assume FreeBSD
is being built with a C++11 compiler available, we can use BSDL dtc
unconditionally and retire the GPL dtc.

GPL dtc now has FreeBSD CI support via Cirrus-CI to help ensure it
continues to build/work on FreeBSD and is available in the ports tree
if needed.

The copy of (copyfree licensed) libfdt that we actually use is in
sys/contrib/libfdt so the extra copy under contrib/dtc/libfdt can be
removed along with the rest of the GPL dtc.

Reviewed by:	kevans, ian, imp, manu, theraven
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23192
2020-02-29 17:10:54 +00:00
Dimitry Andric
91019ea7d4 Merge ^/head r358400 through r358465. 2020-02-29 15:08:14 +00:00
Ed Maste
9fdab7a316 remove contrib/gperf
gperf was used only as a build tool for GCC, and is not needed after
r358454.

Sponsored by:	The FreeBSD Foundation
2020-02-29 13:25:38 +00:00
Ed Maste
c45018041d retire the LLVM_LIBUNWIND option
LLVM's libunwind is used on all FreeBSD-supported CPU architectures and
is a required component.

Reviewed by:	brooks (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23123
2020-02-29 12:43:43 +00:00
Ed Maste
a9854bc381 Remove contrib/gcc and contrib/gcclibs
GCC 4.2.1 was disconnected from FreeBSD in r358454.

Sponsored by:	The FreeBSD Foundation
2020-02-29 12:40:27 +00:00
Jung-uk Kim
8c9735fbe0 Plug possible memory leaks in the previous patch.
Two DH_free() calls were accidentally removed.

Pointyhat to:	jkim
2020-02-27 23:06:12 +00:00
Jung-uk Kim
a5f8e6f658 Do not free p and g parameters after calling DH_set0_pqg(3).
It is specifically mentioned in the manual page.  Note it has no functional
change in reality because DH_set0_pqg() cannot fail when both p and g are
not NULL.
2020-02-27 22:36:16 +00:00
Jung-uk Kim
a33b334336 Fix style inconsistencies near our OpenSSL 1.1.x patch. 2020-02-27 22:02:00 +00:00
Jung-uk Kim
3ab9782ad3 Fix a white space. 2020-02-27 20:46:30 +00:00
Brooks Davis
8582cd3101 Merge commit 7214f7a79 from llvm git (by Sam Elliott):
[RISCV] Lower llvm.trap and llvm.debugtrap

  Summary:
  Until this commit, these have lowered to a call to abort().

  `llvm.trap()` now lowers to `unimp`, which should trap on all systems.

  `llvm.debugtrap()` now lowers to `ebreak`, which is exactly what this
  instruction is for.

  Reviewers: asb, luismarques

  Reviewed By: asb

  Tags: #llvm

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

This fixes miscompilation resulting in linking failures with
INVARIANTS disabled.

Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D23857
2020-02-27 20:08:46 +00:00
Hiroki Sato
43092b7d08 Fix poor performance of ftp(1) due to small SO_SNDBUF and SO_RCVBUF.
ftp(1) from vendor/tnftp always tried the following for
every TCP connection:

1. Get the current buffer length of SO_SNDBUF and SO_RCVBUF
   by getsockopt(2).

2. Invoke setsockopt(2) to set them to the same values
   after checking if they are in a range between 8 KiB to 8 MiB.

This behavior broke dynamic buffer sizing enabled by
default (net.inet.tcp.{recv,send}buf_auto sysctls) and
led to a very poor transfer rate.  The fetch(1) utility
does not have this problem.

This change prevents SO_SNDBUF and SO_RCVBUF from configuring
when the buffer auto-sizing is enabled unless the buffer sizes are
explicitly specified.

PR:		240827
Spotted by:	Yuichiro NAITO
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D23732
2020-02-27 19:49:59 +00:00
Hiroki Sato
9b429e2192 Fix broken STARTTLS when SharedMemoryKey is enabled.
OpenSSL 1.1 API patch for sendmail had a bug which
prevented sm_RSA_generate_key() function from working.
This function is used to generate a temporary RSA key
for a shared memory region used for TLS processing.
Note that 12.0 and 12.1-RELEASE include this bug.

This affects only if SM_CONF_SHM compile-time
option (enabled by default) and SharedMemoryKey
run-time option (not enabled by default) in a .cf file are
specified.  The latter corresponds to confSHARED_MEMORY_KEY in
a .mc file.

PR:		242861
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D23734
2020-02-27 19:40:29 +00:00
Dimitry Andric
4739579419 Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
commit llvmorg-10.0.0-rc2-70-ge5cb70267e7), and bump versions.
2020-02-27 19:04:39 +00:00
Dimitry Andric
21054a9b07 Merge commit 2e24219d3 from llvm git (by Hans Wennborg):
[MC][ARM] Resolve some pcrel fixups at assembly time (PR44929)

  MC currently does not emit these relocation types, and lld does not
  handle them. Add FKF_Constant as a work-around of some ARM code after
  D72197. Eventually we probably should implement these relocation
  types.

  By Fangrui Song!

  Differential revision: https://reviews.llvm.org/D72892

This re-enables using the arm 'adr' pseudo instruction on global symbols
again.  It was broken as a side-effect of upstream commit 2bfee35cb,
which lead to "error: unsupported relocation on symbol" when assembling
such constructs, which are used in e.g. sys/arm/arm/locore-v[46].S.

PR:		244251
2020-02-27 18:49:49 +00:00
Dimitry Andric
43c7dd6b59 Merge ^/head r358075 through r358130. 2020-02-19 21:03:06 +00:00
Baptiste Daroussin
e18651243e Update to 6.2-20200215
While I didn't plan another upgrade, This version incorporate fixes from
kevans@ so let's upgrade to it
2020-02-19 17:09:08 +00:00
Dimitry Andric
abaad9d77d Merge ^/head r358049 through r358074. 2020-02-18 17:59:37 +00:00