Commit 86e1e05
objtool: Update section header before relocations
The libelf implementation from elftoolchain has a safety check in
gelf_update_rel[a] to check that the data corresponds to a section
that has type SHT_REL[A] [0]. If the relocation is updated before
the section header is updated with the proper type, this check
fails.
To fix this, update the section header first, before the relocations.
Previously, the section size was calculated in elf_rebuild_reloc_section
by counting the number of entries in the reloc_list. However, we
now need the size during elf_write so instead keep a running total
and add to it for every new relocation.
[0] https://sourceforge.net/p/elftoolchain/mailman/elftoolchain-developers/thread/CAGw6cBtkZro-8wZMD2ULkwJ39J+tHtTtAWXufMjnd3cQ7XG54g@mail.gmail.com/
Signed-off-by: Michael Forney <[email protected]>
Reviewed-by: Miroslav Benes <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
Link: https://lore.kernel.org/r/[email protected]1 parent b46179d commit 86e1e05
1 file changed
+17
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
| |||
977 | 978 | | |
978 | 979 | | |
979 | 980 | | |
980 | | - | |
| 981 | + | |
981 | 982 | | |
982 | 983 | | |
983 | | - | |
| 984 | + | |
984 | 985 | | |
985 | 986 | | |
986 | 987 | | |
987 | | - | |
988 | | - | |
| 988 | + | |
989 | 989 | | |
990 | 990 | | |
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
995 | | - | |
| 995 | + | |
996 | 996 | | |
997 | 997 | | |
998 | | - | |
999 | | - | |
1000 | 998 | | |
1001 | 999 | | |
1002 | 1000 | | |
| |||
1011 | 1009 | | |
1012 | 1010 | | |
1013 | 1011 | | |
1014 | | - | |
| 1012 | + | |
1015 | 1013 | | |
1016 | 1014 | | |
1017 | | - | |
| 1015 | + | |
1018 | 1016 | | |
1019 | 1017 | | |
1020 | 1018 | | |
1021 | | - | |
1022 | | - | |
| 1019 | + | |
1023 | 1020 | | |
1024 | 1021 | | |
1025 | 1022 | | |
1026 | 1023 | | |
1027 | 1024 | | |
1028 | 1025 | | |
1029 | | - | |
| 1026 | + | |
1030 | 1027 | | |
1031 | 1028 | | |
1032 | | - | |
1033 | | - | |
1034 | 1029 | | |
1035 | 1030 | | |
1036 | 1031 | | |
| |||
1048 | 1043 | | |
1049 | 1044 | | |
1050 | 1045 | | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | 1046 | | |
1059 | | - | |
1060 | | - | |
| 1047 | + | |
| 1048 | + | |
1061 | 1049 | | |
1062 | 1050 | | |
1063 | 1051 | | |
| |||
1117 | 1105 | | |
1118 | 1106 | | |
1119 | 1107 | | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | 1108 | | |
1127 | 1109 | | |
1128 | 1110 | | |
| |||
1133 | 1115 | | |
1134 | 1116 | | |
1135 | 1117 | | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1136 | 1124 | | |
1137 | 1125 | | |
1138 | 1126 | | |
| |||
0 commit comments