Commit Graph

439 Commits

Author SHA1 Message Date
Ed Maste
12899612dd Add deprecation notice to objdump man page
PR:		229046
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13881
2018-06-15 17:03:49 +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
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
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
Justin Hibbits
7a174c3469 Do exception offset computations in 64 bits, not 32.
This fixes clang-built binaries on a gcc powerpc64 world.  Gets us one step
closer to a clang-built world.  The same change was made in later upstream
binutils.

Submitted by:	rdivacky
MFC after:	2 weeks
2017-10-11 02:39:20 +00:00
Ryan Libby
1a11bb8f76 gnu binutils: FSGSBASE assembly/disassembly
Enable the in-tree binutils to assemble and disassemble amd64 FSGSBASE
instructions (rdfsbase, rdgsbase, wrfsbase, wrgsbase), used in the base
system since r322763.

This gives one last gasp for in-tree gcc, and provides a small
enhancement for in-tree binutils objdump.

Reviewed by:	dim, kib
Approved by:	markj (mentor)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12222
2017-09-05 19:04:07 +00:00
Ed Maste
bdab1e7024 gas: add parens to clarify expression and eliminate clang warning
Building mips64 w/ Clang failed with -Werror,-Wshift-negative-value
error: shifting a negative signed value is undefined
2017-08-18 21:20:38 +00:00
Ed Maste
f2356007d5 gas: fix "format string is not a string literal" errors on mips
Sponsored by:	The FreeBSD Foundation
2017-08-18 18:26:30 +00:00
Ed Maste
e80e4f3aca bfd: cast BFD_ALIGN to fix clang error on mips
error: implicit conversion from 'bfd_vma' (aka 'unsigned long long')
to 'int' changes value from 18446744073709551615 to -1
  return BFD_ALIGN (ret, 16);
  ~~~~~~ ^~~~~~~~~~~~~~~~~~~
note: expanded from macro 'BFD_ALIGN'
   : ~ (bfd_vma) 0)
     ^~~~~~~~~~~~~

Sponsored by:	The FreeBSD Foundation
2017-08-18 18:20:51 +00:00
Pedro F. Giffuni
8bc5011859 Align text correctly by using tabs instead of spaces.
The text was copy-pasted from the lines that carry the bogus spaces.
This is a non-functional change.
2017-05-27 20:01:50 +00:00
Pedro F. Giffuni
3a17f73727 Bring some rough support for FreeBSD S/390 to the GNU toolchain.
This is no-op and only for reference: the S/390 port seems to be elusive
in the BSDs so it is convenient to keep some trace from past efforts.
It is likely newer attempts will focus on a newer toolchain using clang
instead.

Obtained from:	Perforce depot/projects/s390
2017-05-23 16:38:10 +00:00
Michal Meloun
7f20e1614f Fix parsing of 'vmov Q<n>.F32,Q<n>.F32' instruction.
parse_qfloat_immediate() accidentaly parses register with size
qualifier as immediate constant (It takes '<n>.' substring as
valid floating point constant).

Due to this, slightly reorder cases in parse_neon_mov() and move parsing of
vmov with immediate constant to last place.

MFC after:	2 weeks
2017-05-10 05:07:41 +00:00
Ed Maste
bd4e40546c use INT3 instead of NOP for x86 binary padding
We should never end up executing the inter-function padding, so we
are better off faulting than silently carrying on to whatever function
happens to be next.

Note that LLD will soon do this by default (although it currently pads
with zeros).

Reviewed by:	dim, kib
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10047
2017-03-19 00:22:13 +00:00
Justin Hibbits
e0b603cb9e Add rfdi opcode to binutils
The rfdi instruction is part of the e500mc and derivative cores.  It came into
binutils in a GPLv3 patch, along with the rest of the e500mc instruction set.
Currently only rfdi is planned to be used, so rather than attempt to backport
the full patch, take a surgical route and add instructions as needed.

MFC after:	2 weeks
2017-02-01 02:42:45 +00:00
Ed Maste
5be48d84be add octeon+ as an alias for octeon in GCC & binutils
In r208737 jmallett@ added support for the "mips64r2" architecture
and "octeon" CPU, and the saa/saad instructions.

Upstream binutils also added the "octeon+" CPU, and the saa/saad
instructions are only available in octeon+, not octeon.  Since our
base system tool chain already accepts saa/saad with -march=octeon,
just allow octeon+ as an alias.

This allows the use of octeon+ in kernel config files, for use with both
external tool chain and in-tree GCC/binutils.

PR:		216516
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2017-01-27 21:31:32 +00:00
Pedro F. Giffuni
6e183b4b25 libbfd: make sure variables are initialized before using them.
Initialize l_sec_contents to make sure that free(l_sec_contents) is called
on valid pointers.

Obtained from:	OpenBSD (partial CVS rev 1.18)
MFC after:	5 days
2016-12-16 00:35:59 +00:00
Pedro F. Giffuni
d90714d2c5 libbfd: drop unnecessary variable increment.
Do not increment `s' before it is initialized. At the time
of the increment, `s' is otherwise unused anyway.

Obtained from:	OpenBSD (CVS rev 1.11)
2016-12-16 00:23:59 +00:00
Justin Hibbits
dc9b124d66 Create a new MACHINE_ARCH for Freescale PowerPC e500v2
Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU.  The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive.  Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement.  setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).

Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.

Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.

Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used.  However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.

Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI.  Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.

Reviewed By:	bdrewery, imp
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D5683
2016-10-22 01:57:15 +00:00
Brooks Davis
f1f548d0e9 Spell MIPS more traditionally in "bfd_elf32_ntradbigmips_vec".
Sponsored by:	DAPRA, AFRL
2016-08-24 00:00:54 +00:00
Justin Hibbits
c12dee326f Check the first byte of the array for NUL, instead of the array as a NULL pointer
The partition_name field is an array, so can never be NULL itself.  Check only
the first byte instead.

This was found when test building with clang, but I'm not sure how it passes
gcc's warnings either.
2016-08-06 15:10:14 +00:00
Pedro F. Giffuni
717464d821 binutils: fix "Bad value" error in bfd for MIPS when using -Bsymbolic.
From OpenBSD's log:

Inspired by https://sourceware.org/ml/binutils/2010-08/msg00333.html,
but expressed differently so there are no GPLv3 issues.

Obtained from:	OpenBSD (CVS rev. 1.7)
MFC after:	1 month
2016-07-21 15:26:21 +00:00
Ed Schouten
a25e1dd4df Replace local prototype of basename() with an inclusion of <libgen.h>.
libiberty currently defines the prototype for basename() itself instead
of using <libgen.h>. It still uses the BSD-style prototype instead of
the POSIX one, meaning that if FreeBSD would switch over to the POSIX
one, you wouldn't be able to use libiberty.h and libgen.h in a single
source file. It turns out that kgdb does this. Patch up libiberty to
just include <libgen.h>.

I'm currently talking to upstream to see whether we can come up with a
more complete solution that could be integrated, but for our
unmaintained copy of GDB in base, let's just apply the simplest
workaround possible.

Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D6631
2016-05-29 16:10:01 +00:00
Pedro F. Giffuni
3b6f4eae15 gas: Implement the .inst assembler directive for arm.
We normally use the binutils from ports but on other systems this
is required for building gcc 4.9.

Obtained from:	OpenBSD (CVS rev. 1.5)
MFC after:	3 weeks
2016-05-20 20:01:10 +00:00
Pedro F. Giffuni
2c9dee79ef gas/config/tc-arm.c: Minor re-sorting to match upstream history.
No functional change.

MFC after:	2 weeks
2016-05-20 15:14:38 +00:00
Dimitry Andric
72e8ce06c0 Fix a problem in ld, causing it to sometimes print messages similar to
"invalid string offset 65521 >= 27261 for section `.strtab'". for object
files produced by recent versions of clang.

In BFD's elf_create_symbuf() function, the size of the symbol buffer
('ssymbuf') is not calculated correctly, and the initial value for the
'ssym' variable is off by one, since 'ssymbuf' has shndx_count + 1
members.

MFC after:	1 week
2016-02-22 22:16:32 +00:00
Ian Lepore
e1ba387e11 Unconditionally set e_ident[OSABI]=ELFOSABI_FREEBSD in arm binary headers.
When the armv6 support was imported from a project branch, this complex
conditional logic and related #define'd values came along, but it's really
not clear what the intent of it all was.  The effect, however, was that
OSABI was always set to zero, which is "UNIX System V ABI".  Having the wrong
value there causes pkg(8) to avoid looking inside arm elf binaries to
determine shared-lib required/provides info for packaging.
2016-02-21 14:59:24 +00:00
Ian Lepore
dfd3a89ff0 Add the MOVT/MOVW types to the list of relocs which do not generate .plt
entries.  This fixes the segfaults in arm userland code compiled with
-march= or -mcpu= values that allow the compiler to generate movw/movt
sequences to load 32-bit constants.
2015-12-30 23:04:08 +00:00
Ian Lepore
5dbfbb1512 Correct the code for sign-extending a 16 bit value. As near as I can tell
this is effectively a no-op -- the addend term in MOVT/MOVW relocations
always seems to be zero.  But this is correct and the old code wasn't.
2015-12-29 15:23:03 +00:00
Dimitry Andric
54e1e8cb67 In binutils' arm-dis.c, avoid left-shifting a negative number.
Submitted by:	dan.mcgregor_usask.ca (Dan McGregor)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D3376
2015-09-22 09:35:35 +00:00
Dimitry Andric
a0c1575d2f In GNU as, avoid left-shifting negative integers, which is undefined.
MFC after:	3 days
2015-08-09 11:06:40 +00:00
Andrew Turner
53ee135632 Copy new attribute types when linking. bfd will copy attributes as needed,
however it will fail to output them if the type is not set correctly. This
can happen when it finds an attribute it hasn't seen before, for example
when building shared objects it will use the attributes from crti.o, hwever
this file has no attributes set.

Differential Revision:	https://reviews.freebsd.org/D2413
Reviewed by:	imp
2015-05-05 10:35:29 +00:00
Warner Losh
729a1e1dec For eabi 5 (what FreeBSD uses), be sure to tag all executables and
shared libraries as either SOFT or HARD float to comply with the EABI
standard.

Differential Revision: https://reviews.freebsd.org/D2401
2015-05-03 22:51:42 +00:00
Warner Losh
f321ea7845 When merging the floating point type attribute, and reporting an error
when things don't match, report which file has them and which one
doesn't correctly.

Differential Revision: https://reviews.freebsd.org/D2400
2015-05-03 22:51:29 +00:00
Andrew Turner
ef25e82143 More ARM EABI object attributes in binutils. This adds support to binutils
to include the Unaligned Access and Floating-point Half-precision
attributes. the former marks ELF objects that may access ARMv6 style
unaligned data, the latter that the binary uses the VFPv3/Advanced SIMD
half-precision extension.

These may be emmitted by clang so it's best to print a warning when the
linker hits one of them.

Differential Revision:	http://reviews.freebsd.org/D2194
Submitted by:	Michal Meloun <meloun@miracle.cz>
MFC after:	1 week
2015-04-03 19:33:26 +00:00
Baptiste Daroussin
1d0f6813ac Remove pregenerated text version of the texinfo documentation 2015-03-02 17:25:03 +00:00
Baptiste Daroussin
7bb36fb551 Generate manpage out of the texinfo files using texi2mdoc 2015-03-02 17:20:34 +00:00
Ed Maste
4b8807a4d3 GNU nm: Avoid NULL dereference
bfd_dwarf2_find_line() calls find_line() with NULL functionname_ptr,
which resulted in a crash on certain ELF objects.

This change was implemented independently from upstream binutils, but
I have checked that the crash does not happen there.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2015-02-25 22:12:37 +00:00
Nathan Whitehorn
8a5843ad02 Add some opcodes for assembling forthcoming VSX (Vector-Scalar eXtension)
support in the kernel. Userspace programs are expected to rely on LLVM's
integrated assembler or newer binutils.
2015-02-22 20:52:29 +00:00
Tijl Coosemans
99e1a2bc3a Fix ldscripts such that ld(1) collects the .fini_array section in the same
order as the .init_array section.  Finalisation routines need to be called
in the opposite order as their corresponding initialisation routines but
rtld(1) handles that by calling the function pointers in .fini_array in
reverse order.

Reviewed by:	kib
MFC after:	2 weeks
2015-02-11 17:25:23 +00:00
Baptiste Daroussin
bbb0fbde9a Add pregenerated documentation for as(1) and ld(1) 2015-01-04 00:58:30 +00:00
Baptiste Daroussin
4a3e081c7b Fix generating documentation with modern texinfo 2015-01-04 00:54:29 +00:00
Baptiste Daroussin
321f9e5ad9 Fix generating documents with modern texinfo 2015-01-04 00:44:24 +00:00
Dimitry Andric
db39fc2a01 In contrib/binutils/bfd/elf32-ppc.c, avoid warnings about case values
not being in the enumerated type 'enum elf_ppc_reloc_type', by casting
the switch argument to int.

MFC after:	3 days
2014-12-29 00:10:43 +00:00
Dimitry Andric
efabc957c5 In contrib/binutils/gas/config/tc-ppc.c, fix a few -Wformat-security
warnings.

MFC after:	3 days
2014-12-28 21:06:03 +00:00
Pedro F. Giffuni
e63365a089 Backport fix for binutils 11867: .quad directive not assembled correctly
Alan Modra (and Alan's employer) graciously permitted use of his patch
under GPLv2.

Obtained from:	OpenBSD
MFC after:	5 days
2014-12-26 04:33:53 +00:00
Pedro F. Giffuni
32d0bb7e1b gas: use memmove instead of bogus memcpy.
partial_where points into the buffer that begins with buffer_start
so we need to use memmove() to handle the overlap.
Sourceware-PR 11456.

Obtained from:	OpenBSD (CVS rev. 1.2)
MFC after:	3 days
2014-12-26 03:03:41 +00:00
Justin Hibbits
e5701220a8 Make gas parse '__tls_get_addr(foo@tlsgd)'.
Corresponds to 727fc41e077139570ea8b8ddfd6c546b2a55627c.

This allows us to use -no-integrated-as with clang, if we prefer.

Obtained from:	binutils-gdb (Relicensed from Alan Modra as GPLv2)
MFC after:	2 weeks
X-MFC-with:	r275718
2014-12-18 03:12:46 +00:00
Justin Hibbits
ff0bab9760 Add new PowerPC relocations to binutils
Summary:
LLVM/Clang generates relocations that our binutils doesn't understand, but newer
binutils does.  I got permission from the author of a series of patches to
relicense them as GPLv2 for use in FreeBSD.  The upstream git hashes are:

ac2df442ac7901f00af15b272fc48b594b433713
2b95367962dc14f69d3c338c4d54195266e2e169
102890f04c44b64cf5cef4588267dd9f24086ac7
b7fcf6f6bb53b5027e111107f5416769cb9a5798
1d483afedd5a628dc84fb58d1d570f79fdfbfa7b
90aecf7a80c1cefeb45fc10a6cd02c8338e34b4c
3a71aa26df2a372a58e9c11ef9ba51fd0e83320a
727fc41e077139570ea8b8ddfd6c546b2a55627c

With the import of clang 3.5, and a few backported patches, we should be able to
move powerpc and powerpc64 to clang-as-cc soon.

Test Plan: Passes make tinderbox, so no regressions.  Binaries built with clang
run on powerpc64.

Reviewers: #committers, dim

Reviewed By: dim

Differential Revision: https://reviews.freebsd.org/D1297

Obtained from:	Alan Modra, upstream binutils-gdb git
MFC after:	3 weeks
Relnotes:	yes
2014-12-12 03:58:51 +00:00
Andrew Turner
6ed7db33bc Fix mrc and mrc2 with APSR_nzcv. Binutils encodes it internally as 0 where
we need it to be set to 15 for it to be equivalent to r15.

MFC after:	1 week
X-MFC with:	r275415
Sponsored by:	ABT Systems Ltd
2014-12-07 21:47:19 +00:00