[llvm-commits] [llvm] r75828 - in /llvm/trunk/lib: CodeGen/ELF.h CodeGen/ELFCodeEmitter.cpp CodeGen/ELFWriter.cpp CodeGen/ELFWriter.h Target/X86/X86ELFWriterInfo.cpp

Reid Kleckner rnk at mit.edu
Wed Aug 19 09:44:51 PDT 2009


I just noticed that this patch introduces a memory leak for the ELFSym
objects.  When you clear out the vector, you need to delete all the
pointers, or you could switch it back to being pass-by-value.

Reid

On Wed, Jul 15, 2009 at 8:33 PM, Bruno Cardoso
Lopes<bruno.cardoso at gmail.com> wrote:
> Hi Bill,
>
> On Wed, Jul 15, 2009 at 8:21 PM, Bill Wendling<isanbard at gmail.com> wrote:
>> Hi Bruno,
>>
>>> --- llvm/trunk/lib/CodeGen/ELF.h (original)
>>> +++ llvm/trunk/lib/CodeGen/ELF.h Wed Jul 15 15:49:10 2009
>>> @@ -52,6 +52,70 @@
>>>     EV_CURRENT = 1
>>>   };
>>>
>>> +  /// ELFSym - This struct contains information about each symbol that is
>>> +  /// added to logical symbol table for the module.  This is eventually
>>> +  /// turned into a real symbol table in the file.
>>> +  struct ELFSym {
>>> +    // The global value this symbol matches. This should be null if the symbol
>>> +    // is not a global value.
>>> +    const GlobalValue *GV;
>>> +
>>> +    // ELF specific fields
>>> +    unsigned NameIdx;         // Index in .strtab of name, once emitted.
>>> +    uint64_t Value;
>>> +    unsigned Size;
>>> +    uint8_t Info;
>>> +    uint8_t Other;
>>> +    unsigned short SectionIdx;
>>> +
>>> +    // Symbol index into the Symbol table
>>> +    unsigned SymTabIdx;
>>> +
>>> +    enum {
>>> +      STB_LOCAL = 0,
>>> +      STB_GLOBAL = 1,
>>> +      STB_WEAK = 2
>>> +    };
>>> +
>>> +    enum {
>>> +      STT_NOTYPE = 0,
>>> +      STT_OBJECT = 1,
>>> +      STT_FUNC = 2,
>>> +      STT_SECTION = 3,
>>> +      STT_FILE = 4
>>> +    };
>>> +
>>
>> Please comment what these enums are for.
>>
>>> +  // Emit a symbol for each section created until now, skip null section
>>> +  for (unsigned i = 1, e = SectionList.size(); i < e; ++i) {
>>
>> Please use iterators to go through this vector.
>>
>>
>>> +  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
>>> +    ELFSection &S = *SectionList[i];
>>>
>> Same here.
>>
>>
>>> +  for (unsigned i = 0, e = SymbolList.size(); i < e; ++i) {
>>> +    ELFSym &Sym = *SymbolList[i];
>>>
>> And here.
>>
>>> +  for (i = 0, e = SymbolList.size(); i < e; ++i) {
>>
>> Ditto.
>>
>>
>>> +  for (i = 0, e = OtherSyms.size(); i < e; ++i)
>>
>> Same.
>>
>>> +  // Emit all the symbols to the symbol table.
>>> +  for (unsigned i = 0, e = SymbolList.size(); i < e; ++i) {
>>
>> Ditto.
>>
>>
>>> +  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
>>
>> Here.
>>
>>> +  // Adjust alignment of all section if needed, skip the null section.
>>> +  for (unsigned i=1, e=SectionList.size(); i < e; ++i) {
>>
>> Here.
>>
>>
>>> +  for (unsigned i=0, e=SectionList.size(); i < e; ++i) {
>>
>> Here.
>
> Ok! thanks :)
>
>> Thanks!
>> -bw
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list