scripts: Make sortextable handle relocations.
PATCH 1/1 scripts: Make sortextable handle relocations.
From: David Daney <[email protected]>
If there are relocations on the __ex_table section, they must be fixed up after the table is sorted.
Also use the unaligned safe accessors from tools/{be,le}_byteshift.h
---
This should address HPA's concerns about the i386 relocations. The i386 kernel still boots after the sort, but I don't know how to test the relocations, but they sure do look nice! My MIPS64 kernels still boot too, so that is also good.
scripts/Makefile | 2 + scripts/sortextable.c | 123 +++++++++++++++++++++++-------------------- scripts/sortextable.h | 138 +++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 178 insertions(+), 85 deletions(-)
scripts/Makefile +2 -0
@@ -15,6 +15,8 @@ hostprogs-$(CONFIG_IKCONFIG) += bin2c hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable +HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include + always := $(hostprogs-y) $(hostprogs-m) # The following hostprogs-y programs are only build on demand
scripts/sortextable.c +66 -57
194 lines not on this page · raw message
scripts/sortextable.h +110 -28
223 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 7 lines · David Daney
From: David Daney <[email protected]>
If there are relocations on the
__ex_tablesection, they must be fixed up after the table is sorted.Also use the unaligned safe accessors from
tools/{be,le}_byteshift.h
Quoted 8 lines
Signed-off-by David Daney <[email protected]>---
This should address HPA's concerns about the i386 relocations. The i386 kernel still boots after the sort, but I don't know how to test the relocations, but they sure do look nice! My MIPS64 kernels still boot too, so that is also good.
Hi...
This works for absolute relocations of the REL type, but not for relocations of the RELA type nor for non-absolute relocations (moving those changes the meaning.)
I think Linus is right and the right thing to do is to switch to using relative entries in the exception table; I am currently testing a patchset to do exactly that (on x86). It also has the benefit of making the table half the size on x86-64. Then we can just zero out the .rel[a]__ex_table section and be done with it.
The trick, of course, is that sorting a relative table is slightly different than sorting an absolute table -- the way I'm doing it for the in-kernel sorter (still needed for modules) is to add the intra-section offset to each entry (both sides) before sorting, then doing a *signed* sort, then denormalize again. Alpha does it differently, with custom compare and swap routines.
-hpa
Quoted 17 lines · H. Peter Anvin
Quoted 7 lines · David Daney
From: David Daney<[email protected]>
If there are relocations on the
__ex_tablesection, they must be fixed up after the table is sorted.Also use the unaligned safe accessors from
tools/{be,le}_byteshift.hQuoted 8 lines
Signed-off-by David Daney<[email protected]>---
This should address HPA's concerns about the i386 relocations. The i386 kernel still boots after the sort, but I don't know how to test the relocations, but they sure do look nice! My MIPS64 kernels still boot too, so that is also good.
Quoted 5 lines
Hi...
This works for absolute relocations of the REL type, but not for relocations of the RELA type nor for non-absolute relocations (moving those changes the meaning.)
The program explicitly only handles MIPS and x86.
x86_64 and MIPS never have relocations, and x86_32 is always REL, so that is handled
Also x86_32 is only emitting R_386_32 and those are handled.
Quoted 6 lines
I think Linus is right and the right thing to do is to switch to using relative entries in the exception table; I am currently testing a patchset to do exactly that (on x86). It also has the benefit of making the table half the size on x86-64. Then we can just zero out the .rel[a]__ex_table section and be done with it.
That's fine.
In any event we want to do build time sorting, this patch improves the original sortextable, so may be worthwhile as purely a cleanup. I wanted to fix the relocation breakage, even if the eventual solution needs to be somewhat different.
Quoted 10 lines
The trick, of course, is that sorting a relative table is slightly different than sorting an absolute table -- the way I'm doing it for the in-kernel sorter (still needed for modules) is to add the intra-section offset to each entry (both sides) before sorting, then doing a *signed* sort, then denormalize again. Alpha does it differently, with custom compare and swap routines.
-hpa
Quoted 7 lines · David Daney
Quoted 6 lines
I think Linus is right and the right thing to do is to switch to using relative entries in the exception table; I am currently testing a patchset to do exactly that (on x86). It also has the benefit of making the table half the size on x86-64. Then we can just zero out the .rel[a]__ex_table section and be done with it.
Quoted 7 lines
That's fine.
In any event we want to do build time sorting, this patch improves the original sortextable, so may be worthwhile as purely a cleanup. I wanted to fix the relocation breakage, even if the eventual solution needs to be somewhat different.
Yes... let me finish the patchset and then you can look at what is needed.
-hpa
Quoted 16 lines · H. Peter Anvin
Quoted 7 lines · David Daney
Quoted 6 lines
I think Linus is right and the right thing to do is to switch to using relative entries in the exception table; I am currently testing a patchset to do exactly that (on x86). It also has the benefit of making the table half the size on x86-64. Then we can just zero out the .rel[a]__ex_table section and be done with it.
Quoted 7 lines
That's fine.
In any event we want to do build time sorting, this patch improves the original sortextable, so may be worthwhile as purely a cleanup. I wanted to fix the relocation breakage, even if the eventual solution needs to be somewhat different.
Quoted 4 lines
Yes... let me finish the patchset and then you can look at what is needed.
-hpa
The patchset is finished and is in the x86/extable branch of the -tip tree. Any way I can convinc you to produce a patch(set) on top of that branch?
-hpa