Re: Problems with static variables and GNU map files


Paul Sokolovsky
 

Hello Marti,

On Wed, 25 Oct 2017 23:56:47 -0400
Marti Bolivar <marti.bolivar@linaro.org> wrote:

Why not just #define static SOMETHING_ELSE as needed?
Because "static" has different semantics in different contexts. For
example, we don't want to touch "static inline" functions. Though, based
on the number of changes, I guess it would be easier to add a #define
for static inline functions than for everything else...


On 19 October 2017 at 15:08, Paul Sokolovsky
<paul.sokolovsky@linaro.org> wrote:

Hello,

A usecase (one of many): I want to see what network interface
structures go into my Zephyr binary. Of course, I look at the
linker map file, and ... see nothing:

net_if 0x000000000041fa80 0x2a0 load address
0x00000000000150bc
0x000000000041fa80 __net_if_start = .
*(.net_if.*)
.net_if.data 0x000000000041fa80 0x2a0 drivers/built-in.o
*(SORT(.net_if.*))
0x000000000041fd20 __net_if_end = .

That's because netif structures are defined as static, and GNU
linker takes that as an incentive to conceal them from the map
file. This issue was reported few years ago as
https://sourceware.org/bugzilla/show_bug.cgi?id=16566 with no
feedback, so apparently nothing is going to happen.


Proposal:

Let's have

#define STATIC static

And use STATIC everywhere a static var is defined. This way, it can
be redefined in one place to produce a relevant map file (let's
also have unique names for all variables, yeah).


--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog
_______________________________________________
Zephyr-devel mailing list
Zephyr-devel@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-devel


--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog

Join devel@lists.zephyrproject.org to automatically receive all group messages.