]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: remove sizer section and related code main master
authorBenjamin Berg <benjamin.berg@intel.com>
Fri, 3 May 2024 11:12:06 +0000 (13:12 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 5 Jun 2024 11:46:13 +0000 (13:46 +0200)
With commit 338059ace9d0 ("iw: change __cmd section scheme to fit
gcc/clang"), the __cmd section only includes pointers to struct cmd
rather than the struct itself. This means that the code to measure the
spacing is not needed anymore and can be dropped.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
iw.c

diff --git a/iw.c b/iw.c
index 35308ba3244a3750cf71491124b5c74d542dda73..c99edb1292e750d7403722392cfe44bfa7ad75ca 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -87,8 +87,6 @@ static void nl80211_cleanup(struct nl80211_state *state)
        nl_socket_free(state->nl_sock);
 }
 
-static int cmd_size;
-
 extern struct cmd *__start___cmd[];
 extern struct cmd *__stop___cmd;
 
@@ -555,33 +553,12 @@ int handle_cmd(struct nl80211_state *state, enum id_input idby,
        return __handle_cmd(state, idby, argc, argv, NULL);
 }
 
-/*
- * Unfortunately, I don't know how densely the linker packs the struct cmd.
- * For example, if you have a 72-byte struct cmd, the linker will pad each
- * out to 96 bytes before putting them together in the section. There must
- * be some algorithm, but I haven't found it yet.
- *
- * We used to calculate this by taking the (abs value of) the difference
- * between __section_get and __section_set, but if LTO is enabled then this
- * stops working because the entries of the "__cmd" section get rearranged
- * freely by the compiler/linker.
- *
- * Fix this by using yet another "__sizer" section that only contains these
- * two entries - then the (abs value of) the difference between them will
- * be how they get packed and that can be used to iterate the __cmd section
- * as well.
- */
-static struct cmd sizer1 __attribute__((section("__sizer"))) = {};
-static struct cmd sizer2 __attribute__((section("__sizer"))) = {};
-
 int main(int argc, char **argv)
 {
        struct nl80211_state nlstate;
        int err;
        const struct cmd *cmd = NULL;
 
-       /* calculate command size including padding */
-       cmd_size = labs((long)&sizer2 - (long)&sizer1);
        /* strip off self */
        argc--;
        argv0 = *argv++;