freebsd-dev/sys/mips
Adrian Chadd 1a71a7f2a4 [mips] add support for the "creative" GNU extensions and IRIX hilarity around MIPS LO16/HI16 relocations.
This was .. an interesting headache.

There are two halves:

* The earlier IRIX stuff (yes, early) occasionally would do dead
  code removal and generate multiple consecutive LO16 entries.
  If this is done for REL entries then it's fine - there's no
  state kept between them.  But gcc 5.x seems to do this for
  RELA entries.

eg:

HI1 LO1 HI2 LO2 LO3 HI4 LO4

.. in this instance, LO2 should affect HI2, but LO3 doesn't at all
affect anything.  The matching HI3 was in code that was deleted
as "dead code".

Then, the next one:

* A "GCC extension" allows for multiple HI entries before a LO entry;
  and all of those HI entries use the first LO entry as their basis
  for RELA offset calculations.

It does this so GCC can also do dead code deletion without necessarily
having to geneate fake relocation entries for balanced HI/LO RELA
entries.

eg:

HI1 LO1 HI2 HI3 HI4 LO4 LO5 HI6 LO6 LO7

in this instance, HI{2,3,4} are the same relocation as LO4 (eg .bss)
and need to be buffered until LO4 - then the RELA offset is applied
from LO4 to HI{2,3,4} calculations.

/And/, the AHL from HI4 is used during the LO4 relocation calculation,
just like in the normal (ie, before this commit) implementation.

Then, LO5 doesn't trigger anything - the HI "buffer" is empty,
so there are no HI relocations to flush out.

HI6/LO6 are normal, and LO7 doesn't trigger any HI updates.

Tested:

* AR9344 SoC, kernel modules, using gcc-5.3 (mips-gcc-5.3.0 package)

Notes:

* Yes, I do feel dirty having written this code.

Reviewed by:	imp (after a handful of "this should be on fire" moments wrt gcc and this code)
2016-08-21 00:48:41 +00:00
..
adm5120 Remove NULL checks after M_WAITOK allocations from sys/mips/. 2016-05-11 09:42:24 +00:00
alchemy Remove NULL checks after M_WAITOK allocations from sys/mips/. 2016-05-11 09:42:24 +00:00
atheros [arge] add some extra MDIO debugging support 2016-08-05 17:16:35 +00:00
beri Fix the resource_list_print_type() calls to use uintmax_t. 2016-03-22 22:25:08 +00:00
broadcom mips/broadcom: Implement CFE-based EARLY_PRINTF support. 2016-08-17 20:24:14 +00:00
cavium sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00
conf mips/broadcom: Implement CFE-based EARLY_PRINTF support. 2016-08-17 20:24:14 +00:00
gxemul Add 32-bit support for Gxemul's oldtestmips machine emulation 2013-09-04 20:34:36 +00:00
idt Remove NULL checks after M_WAITOK allocations from sys/mips/. 2016-05-11 09:42:24 +00:00
include [mips] add support for using the MIPS user register for TLS data. 2016-08-07 01:29:55 +00:00
malta Fixed FreeBSD/mips MALTA support for QEMU 2016-06-29 23:33:44 +00:00
mediatek Build etherswitch support for appropriate Ralink/Mediatek SoCs 2016-05-25 06:47:28 +00:00
mips [mips] add support for the "creative" GNU extensions and IRIX hilarity around MIPS LO16/HI16 relocations. 2016-08-21 00:48:41 +00:00
nlm Consistently use device_t 2016-08-09 19:32:06 +00:00
rmi Consistently use device_t 2016-08-09 19:32:06 +00:00
rt305x Remove NULL checks after M_WAITOK allocations from sys/mips/. 2016-05-11 09:42:24 +00:00
sibyte sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00