Re: Identifying declared but unreferenced global variables from a plugin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/17/2016 12:39 PM, Bertram, Alexander wrote:
> Thanks for the pointer.
> 
> But I'm not sure if this is the case here: the global variable is
> unreferenced, but it has external visibility and is ultimately written
> out to the object file as a symbol.
> 
> I've kept digging around in the sources, and it looks like varasm.c
> might be something in the right direction:
> 
>   /* This file handles generation of all the assembler code
>       *except* the instructions of a function.
>       This includes declarations of variables and their initial values.
> 
>       We also output the assembler code for constants stored in memory
>       and are responsible for combining constants with the same value.  */
> 
> So somehow the code in varasm gets a list of these global declarations
> and writes them as data(?) sections in the object file. Where does
> varasm get this list?

varpool.c has 'symbol_table::output_variables' method, it uses
'FOR_EACH_VARIABLE' and 'FOR_EACH_DEFINED_VARIABLE' macros to traverse the lists
of declared/defined variables. These macros are defined in cgraph.h

-- 
Regards,
    Mikhail Maltsev



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux