[ELF][MIPS] Fix calculation of GOT "page address" entries number
authorSimon Atanasyan <simon@atanasyan.com>
Tue, 29 Nov 2016 10:23:46 +0000 (10:23 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Tue, 29 Nov 2016 10:23:46 +0000 (10:23 +0000)
commit80f3d9ce939d0ff796c88ab82248dbfaed95f028
treede9b12c2127c2a411f7a3f38a937598de0371f87
parentc211c6c8844a46f8ac795ef7998b81772bc99103
[ELF][MIPS] Fix calculation of GOT "page address" entries number

If output section which referenced by R_MIPS_GOT_PAGE or R_MIPS_GOT16
relocations is small (less that 0x10000 bytes) and occupies two adjacent
0xffff-bytes pages, current formula gives incorrect number of required "page"
GOT entries. The problem is that in time of calculation we do not know
the section address and so we cannot calculate number of 0xffff-bytes
pages exactly.

This patch fix the formula. Now it gives a correct number of pages in
the worst case when "small" section intersects 0xffff-bytes page
boundary. From the other side, sometimes it adds one more redundant GOT
entry for each output section. But usually number of output sections
referenced by GOT relocations is small.

llvm-svn: 288127
lld/ELF/SyntheticSections.cpp
lld/test/ELF/mips-64-got.s
lld/test/ELF/mips-got-page.s [new file with mode: 0644]
lld/test/ELF/mips-got-redundant.s
lld/test/ELF/mips-got16.s
lld/test/ELF/mips-xgot-order.s