[llvm-commits] Fix for ArchiveReader

Joe Abbey joe.abbey at gmail.com
Sun Mar 6 09:13:20 PST 2011


Do I need to provide a testcase to have this committed?

Cheers,

Joe

On Fri, Mar 4, 2011 at 10:26 AM, Joe Abbey <joe.abbey at gmail.com> wrote:
> Not all archive files have a symbol table in front of it (which would
> make firstFileOffset non-zero). In the case where an archive file, has
> firstFirstOffset != 0, wrong offsets saved to the 'modules' map would
> not always lead to linking failures because when a lookup fails, a
> module is loaded
> (but this time correctly) again via some other code in
> ArchiveReader.cpp. So the problem can be masked because of that.
>
> The root cause of the problem is a defect in ArchiveReader.cpp, inside
> Archive::findModulesDefiningSymbols(). In particular, the code below
>
>          // Insert the Module and the ArchiveMember into the table of
>          // modules.
>          modules.insert(std::make_pair(offset, std::make_pair(M, mbr)));
>
> should be corrected as follows:
>
>          // Insert the Module and the ArchiveMember into the table of
>          // modules.
>          modules.insert(std::make_pair(offset +
> firstFileOffset,std::make_pair(M, mbr)));
>
> The defect is the 'offset' value saved to the 'modules' map. The
> 'modules' map should store the physical file offset of the loaded
> module (which is "offset + firstFileOffset", instead of the "offset"),
> the distance of the loaded module member from the first member in the
> archive file.
>
> Cheers,
>
> Joe
>




More information about the llvm-commits mailing list