[ELF] Fix DT_MIPS_LOCAL_GOTNO value for thunks and linker scripts
authorJames Henderson <jh7370@my.bristol.ac.uk>
Wed, 22 Nov 2017 12:04:21 +0000 (12:04 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Wed, 22 Nov 2017 12:04:21 +0000 (12:04 +0000)
commitf70c5beb228e44861557f6757bbd2f983c964b6b
treec52a9de3c5517f712013264e85b27b4f20ccadb4
parent72e5d69826f93410d6c4ab07e01da9bebf7f4c50
[ELF] Fix DT_MIPS_LOCAL_GOTNO value for thunks and linker scripts

The MIPS GOT section has a number of local entries based on the number of pages
needed for output sections referenced by GOT page relocations. The number is
recorded in the DT_MIPS_LOCAL_GOTNO dynamic section tag. However, the dynamic tag
is added before assignAddresses has been called, meaning that any section size used
to calculate the value will not include size modifications caused by, for example,
linker scripts and thunks.

This change moves the calculation of DT_MIPS_LOCAL_GOTNO until writeTo, by which
time the output section sizes have been finalized.

Reviewers: ruiu, rafael

Differential Revision: https://reviews.llvm.org/D39493

llvm-svn: 318828
lld/ELF/SyntheticSections.cpp
lld/test/ELF/mips-got-script.s [new file with mode: 0644]