Looks like each subdirectory in ELF directory was created as a copy of
some architecture (x86_64 perhaps?) as a template. They contain many
similar-looking code. They are not always identical since they diverged
over time. Some differences between the subdirectories are real, and
some are not but just different.
A patch for ELF often has to update multiple occurrences of
similar-looking code in the subdirectories. r228905 is an example.
This is not a good shape. It's probably time to visit all subdirectories,
and if there's architecture-independent stuff there, move that to the
ELF parent directory.
This patch is a starter. This is not totally architecture-independent
since relocations depend on architecture types, but this reduces the
amount of code from the subdirectories and also cut dependencies between
code, so I think it's not bad as a starter. After submitting this,
we have less code there, which makes it easier to find code duplicates.
We have bunch of predicates for relocations for questions like "is
this relocation is for PLT?" We can say whether a relocation is a PLT
or not, for example, by just looking at the relocation. Currently the
predicates are members of LinkingContext, but no context is needed to
answer to that question. And in general if we can make the same decision
by looking at not both X and Y but only X, the latter is preferred.
It is now clear that some architectures didn't define some predicates.
For example, x86 didn't have a predicate function for the copy relocation.
I think this is a missing feature, we may want to revisit that later.
By moving the code out of LinkingContext, each <arch>LinkingContext
becomes smaller, which helps find duplicates in the subdirectories.