freebsd-skq/sys/mips/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
..
autoconf.c
bcopy.S
bus_space_generic.c Make bus_space_generic properly map/unmap memory (using pmap_mapdev and 2016-02-11 06:24:34 +00:00
busdma_machdep.c Revert r291142. 2015-11-23 11:19:00 +00:00
cache_mipsNN.c
cache.c
cpu.c [mips] fix use-before-initialised. 2016-08-16 07:51:05 +00:00
db_disasm.c Cleanup unnecessary semicolons from the kernel. 2016-04-10 23:07:00 +00:00
db_interface.c Use our nitems() macro when param.h is available. 2016-04-20 15:45:55 +00:00
db_trace.c mips/ddb: fix MIPS backtrace truncation and MIPS32 register printing. 2016-07-12 02:12:31 +00:00
dump_machdep.c
elf_machdep.c [mips] add support for the "creative" GNU extensions and IRIX hilarity around MIPS LO16/HI16 relocations. 2016-08-21 00:48:41 +00:00
elf_trampoline.c
exception.S Implement FBT provider (MD part) for DTrace on MIPS. 2016-05-05 13:54:50 +00:00
fp.S Enable hardfloat for assembly generation. 2015-08-24 19:09:56 +00:00
freebsd32_machdep.c Convert ss_sp in stack_t and sigstack to void *. 2016-01-27 17:55:01 +00:00
gdb_machdep.c
genassym.c [mips] add support for using the MIPS user register for TLS data. 2016-08-07 01:29:55 +00:00
in_cksum.c
inckern.S
intr_machdep.c
libkern_machdep.c
locore.S Get rid of struct proc p_sched and struct thread td_sched pointers. 2016-06-05 17:04:03 +00:00
machdep.c mips: for pointers replace 0 with NULL. 2016-04-15 14:26:24 +00:00
mem.c
minidump_machdep.c As <machine/pmap.h> is included from <vm/pmap.h>, there is no need to 2016-02-22 09:02:20 +00:00
mips_pic.c Return the struct intr_pic pointer from intr_pic_register. This will be 2016-05-18 15:05:44 +00:00
mp_machdep.c
mpboot.S
nexus.c INTRNG: Rework handling with resources. Partially revert r301453. 2016-08-19 10:52:39 +00:00
octeon_cop2_swtch.S
octeon_cop2.c
ofw_machdep.c Fix a copyright glitch before it gets copy-pasted again. I think this must 2016-04-07 18:19:09 +00:00
pm_machdep.c Convert ss_sp in stack_t and sigstack to void *. 2016-01-27 17:55:01 +00:00
pmap.c When attempting to satisfy mmap() requests for superpage alignment on 2016-04-30 19:29:03 +00:00
ptrace_machdep.c
sc_machdep.c
stack_machdep.c As <machine/param.h> is included from <sys/param.h>, there is no need 2016-02-22 09:04:36 +00:00
stdatomic.c
support.S
swtch.S [mips] add support for using the MIPS user register for TLS data. 2016-08-07 01:29:55 +00:00
sys_machdep.c [mips] add support for using the MIPS user register for TLS data. 2016-08-07 01:29:55 +00:00
tick.c Rename ARM_INTRNG and MIPS_INTRNG to INTRNG. This will help with machine 2016-04-15 16:05:41 +00:00
tlb.c sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00
trap.c Use a more conventional spelling of "breakpoint". 2016-08-07 09:02:54 +00:00
uio_machdep.c
uma_machdep.c Include sys/_task.h into uma_int.h, so that taskqueue.h isn't a 2016-02-09 20:22:35 +00:00
vm_machdep.c [mips] add support for using the MIPS user register for TLS data. 2016-08-07 01:29:55 +00:00