freebsd-skq/contrib
John Baldwin eb81f38a62 Fix objcopy for little-endian MIPS64 objects.
MIPS64 does not store the 'r_info' field of a relocation table entry as
a 64-bit value consisting of a 32-bit symbol index in the high 32 bits
and a 32-bit type in the low 32 bits as on other architectures.  Instead,
the 64-bit 'r_info' field is really a 32-bit symbol index followed by four
individual byte type fields.  For big-endian MIPS64, treating this as a
64-bit integer happens to be compatible with the layout expected by other
architectures (symbol index in upper 32-bits of resulting "native" 64-bit
integer).  However, for little-endian MIPS64 the parsed 64-bit integer
contains the symbol index in the low 32 bits and the 4 individual byte
type fields in the upper 32-bits (but as if the upper 32-bits were
byte-swapped).

To cope, add two helper routines in gelf_getrel.c to translate between the
correct native 'r_info' value and the value obtained after the normal
byte-swap translation.  Use these routines in gelf_getrel(), gelf_getrela(),
gelf_update_rel(), and gelf_update_rela().  This fixes 'readelf -r' on
little-endian MIPS64 objects which was previously decoding incorrect
relocations as well as 'objcopy: invalid symbox index' warnings from
objcopy when extracting debug symbols from kernel modules.

Even with this fixed, objcopy was still crashing when trying to extract
debug symbols from little-endian MIPS64 modules.  The workaround in
gelf_*rel*() depends on the current ELF object having a valid ELF header
so that the 'e_machine' field can be compared against EM_MIPS.  objcopy
was parsing the relocation entries to possibly rewrite the 'r_info' fields
in the update_relocs() function before writing the initial ELF header to
the destination object file.  Move the initial write of the ELF header
earlier before copy_contents() so that update_relocs() uses the correct
symbol index values.

Note that this change should really go upstream.  The binutils readelf
source has a similar hack for MIPS64EL though I implemented this version
from scratch using the MIPS64 ABI PDF as a reference.

Discussed with:	jkoshy
Reviewed by:	emaste, imp
Approved by:	re (gjb, kib)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D15734
2018-09-05 20:51:53 +00:00
..
amd Fix a broken "SEE ALSO" section of hlfsd(8). 2018-08-14 20:33:48 +00:00
apr
apr-util
atf atf-sh(3): document atf_init_test_cases(3) fully 2017-06-30 05:49:12 +00:00
binutils Add deprecation notice to objdump man page 2018-06-15 17:03:49 +00:00
blacklist Revert 335888 ("Ensure va_list is declared by including stdarg.h.") 2018-07-03 15:48:34 +00:00
bmake Merge bmake-20180512 2018-05-19 00:26:00 +00:00
bsnmp bsnmpd(8): fix and optimize interface description processing 2018-08-18 10:58:44 +00:00
byacc MFV: r319352 2017-05-31 19:37:23 +00:00
bzip2
com_err
compiler-rt Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 2018-06-29 17:51:35 +00:00
cortex-strings Work around a bug in QEMU when loading data with a load pair instruction 2017-08-26 15:08:27 +00:00
dialog
diff
dma Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0. 2018-06-19 23:43:14 +00:00
dtc
ee
elftoolchain Fix objcopy for little-endian MIPS64 objects. 2018-09-05 20:51:53 +00:00
expat
file file: update to 5.34 2018-08-08 01:33:36 +00:00
flex Terminate filter_create_ext() args with NULL, not 0. 2018-08-08 22:45:30 +00:00
gcc Fix GCC 4.2.1 to honor --sysroot for includes. 2018-06-27 18:14:33 +00:00
gcclibs
gdb Commit forgotten change in gdb allowing to use libedit 2018-02-06 12:17:03 +00:00
gdtoa
gperf
hyperv/tools hyperv: Add VF bringup scripts and devd rules. 2017-07-31 07:18:15 +00:00
ipfilter loadpoolfile() implements a -R (NORESOLVE) option which is not listed 2017-08-05 06:46:06 +00:00
jemalloc Update jemalloc to version 5.1.0. 2018-05-11 00:32:31 +00:00
ldns Upgrade LDNS to 1.7.0. 2018-05-12 12:00:18 +00:00
ldns-host
less MFV r329552: less v530. 2018-02-19 05:10:22 +00:00
libarchive MFV r337744: 2018-08-14 11:42:32 +00:00
libbegemot Update bsnmp to version 1.13. This does not bring user-visible changes. 2018-07-03 08:44:40 +00:00
libc-pwcache
libc-vis Update vis(3) the latest from NetBSD. 2017-11-28 01:35:28 +00:00
libc++ Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 2018-06-29 17:51:35 +00:00
libcxxrt
libdivsufsort
libexecinfo
libgnuregex
libpcap Re-apply r190640. 2018-05-31 09:11:21 +00:00
libstdc++
libucl
libxo Import libxo-0.9.0: 2018-05-23 01:20:31 +00:00
llvm Add an lld option to emit PC-relative relocations for ifunc calls. 2018-08-23 14:58:19 +00:00
lua MFV r337586: lua: Update to 5.3.5 2018-08-14 18:58:01 +00:00
mdocml MFH @ r337607, in preparation for boarding 2018-08-11 04:26:29 +00:00
mknod
mtree
ncurses
netbsd-tests Increase timeout for timedmutex_test:mutex2, timedmutex_test:mutex3 2018-08-06 15:55:58 +00:00
netcat
ngatm
ntp MFV r338092: ntp 4.2.8p12. 2018-08-21 02:38:07 +00:00
nvi
ofed Add udma_barrier definitions for RISC-V 2018-07-22 22:35:17 +00:00
one-true-awk Don't display empty error context. 2017-09-24 05:04:06 +00:00
openbsm auditd(8): Log a better error when no hostname is set in audit_control 2018-07-22 18:06:42 +00:00
opencsd/decoder Import OpenCSD -- an ARM CoreSight(tm) Trace Decode Library. 2018-04-04 12:55:31 +00:00
openpam
openresolv
opie Revert r328492: 2018-01-28 03:16:54 +00:00
pam_modules/pam_passwdqc
pf Fix escaping, otherwise Dx gets translated as the macro for DragonFly. 2018-08-11 00:08:59 +00:00
pjdfstest Pull down pjdfstest 0.1 2017-06-28 09:22:45 +00:00
pnpinfo
processor-trace Import Intel Processor Trace decoder library from 2018-03-19 18:59:15 +00:00
sendmail Don't declare union semun in userspace unless _WANT_SEMUN is defined. 2018-03-02 22:32:53 +00:00
serf
smbfs Fix a stack overflow in mount_smbfs when hostname is too long. 2018-06-25 16:42:49 +00:00
sqlite3 Update private sqlite from sqlite3-3.20.0 to sqlite3-3.23.1 2018-05-08 04:51:15 +00:00
subversion Update svn-1.9.7 to 1.10.0. 2018-05-08 04:52:52 +00:00
tcp_wrappers Reduce the log level of tcpd_warn calls from ERR to WARNING. 2018-08-23 20:44:26 +00:00
tcpdump MFV r333668: 2018-05-29 10:29:04 +00:00
tcsh
telnet telnetd(8): Fix dereference of uninitialized value 'IF' 2018-03-16 20:59:56 +00:00
tnftp Switch the default pager for most commands to less 2018-08-08 19:24:20 +00:00
traceroute When using SCTP for sending probe packets, use INIT chunks for payloads 2018-01-27 19:23:42 +00:00
tzcode
tzdata Import tzdata 2018e 2018-05-04 10:17:27 +00:00
unbound Rename all Unbound binaries and man pages from unbound* to local-unbound*. 2018-05-12 17:10:36 +00:00
unvis
vis
wpa For CID 1394785, add a comment explaining that global->event_buf is 2018-08-21 19:17:35 +00:00
xz MFV r333779: xz 5.2.4. 2018-05-18 06:10:16 +00:00
zlib MFV: r323381 2017-09-10 01:25:15 +00:00