developer | 42c7a43 | 2024-07-12 14:39:29 +0800 | [diff] [blame^] | 1 | From 8609336b71a8ae37238dc3f4ddff251a4698a4fc Mon Sep 17 00:00:00 2001 |
| 2 | From: Benjamin Berg <benjamin.berg@intel.com> |
| 3 | Date: Fri, 3 May 2024 13:12:06 +0200 |
| 4 | Subject: [PATCH 04/10] iw: remove sizer section and related code |
| 5 | |
| 6 | With commit 338059ace9d0 ("iw: change __cmd section scheme to fit |
| 7 | gcc/clang"), the __cmd section only includes pointers to struct cmd |
| 8 | rather than the struct itself. This means that the code to measure the |
| 9 | spacing is not needed anymore and can be dropped. |
| 10 | |
| 11 | Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> |
| 12 | Signed-off-by: Johannes Berg <johannes.berg@intel.com> |
| 13 | --- |
| 14 | iw.c | 23 ----------------------- |
| 15 | 1 file changed, 23 deletions(-) |
| 16 | |
| 17 | diff --git a/iw.c b/iw.c |
| 18 | index 35308ba..c99edb1 100644 |
| 19 | --- a/iw.c |
| 20 | +++ b/iw.c |
| 21 | @@ -87,8 +87,6 @@ static void nl80211_cleanup(struct nl80211_state *state) |
| 22 | nl_socket_free(state->nl_sock); |
| 23 | } |
| 24 | |
| 25 | -static int cmd_size; |
| 26 | - |
| 27 | extern struct cmd *__start___cmd[]; |
| 28 | extern struct cmd *__stop___cmd; |
| 29 | |
| 30 | @@ -555,33 +553,12 @@ int handle_cmd(struct nl80211_state *state, enum id_input idby, |
| 31 | return __handle_cmd(state, idby, argc, argv, NULL); |
| 32 | } |
| 33 | |
| 34 | -/* |
| 35 | - * Unfortunately, I don't know how densely the linker packs the struct cmd. |
| 36 | - * For example, if you have a 72-byte struct cmd, the linker will pad each |
| 37 | - * out to 96 bytes before putting them together in the section. There must |
| 38 | - * be some algorithm, but I haven't found it yet. |
| 39 | - * |
| 40 | - * We used to calculate this by taking the (abs value of) the difference |
| 41 | - * between __section_get and __section_set, but if LTO is enabled then this |
| 42 | - * stops working because the entries of the "__cmd" section get rearranged |
| 43 | - * freely by the compiler/linker. |
| 44 | - * |
| 45 | - * Fix this by using yet another "__sizer" section that only contains these |
| 46 | - * two entries - then the (abs value of) the difference between them will |
| 47 | - * be how they get packed and that can be used to iterate the __cmd section |
| 48 | - * as well. |
| 49 | - */ |
| 50 | -static struct cmd sizer1 __attribute__((section("__sizer"))) = {}; |
| 51 | -static struct cmd sizer2 __attribute__((section("__sizer"))) = {}; |
| 52 | - |
| 53 | int main(int argc, char **argv) |
| 54 | { |
| 55 | struct nl80211_state nlstate; |
| 56 | int err; |
| 57 | const struct cmd *cmd = NULL; |
| 58 | |
| 59 | - /* calculate command size including padding */ |
| 60 | - cmd_size = labs((long)&sizer2 - (long)&sizer1); |
| 61 | /* strip off self */ |
| 62 | argc--; |
| 63 | argv0 = *argv++; |
| 64 | -- |
| 65 | 2.18.0 |
| 66 | |