<div dir="ltr">I see, sorry about that, I realized I got confused because Section also have a "file_vm_addr" in its constructor (in .h, in .cpp it becomes "file_addr"), accessible through GetFileAddress(). But this one seems to actually be a VM space address, not a real file offset.<div>


Some examples:</div><div>- In ObjectFile, comments for parameter file_vm_addr/GetFileAddress() when creating Section: // File VM address == addresses as they are found in the object file</div><div>- SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + offset) < Using GetFileAddress to compute Section load address</div>


<div><br></div><div><div>Since Section used GetFileAddress() for VM addresses as written in assembly, I thought GetFileOffset() would also be in VM space as well (I didn't notice GetFileAddress vs GetFileOffset, thinking all GetFile would work in the same address space).<br>

</div>
<div><br></div><div>Anyway, thanks for the review, now I understand what's wrong and I will change it. However I still need this VM Base Address to be available for my ObjectFile to be available externally, so that lldbProcessWindows can apply module offset. As an example, if PECOFF module is supposed to be loaded at VM Base Address = 0x400000 but actually loaded at 0x500000, debugger needs to call module->SetLoadAddress(offset = 0x500000 - 0x400000), so that all Sections are shifted properly.</div>


<div><br></div><div>Note that all addresses within PECOFF will be written in VM addr space as if module is loaded at 0x400000, which is why it should be considered the Module VM Address, same as Section's file_vm_addr/GetFileAddress() is currently being used for Section VM address offseting.</div>


<div><br></div><div>So, if I understood right:</div><div>- Is it OK to add a function such as ObjectFile::GetVirtualFileAddress() or something like that to represent this concept? If yes, what name?</div><div>- In that case, shouldn't Section::GetFileOffset be renamed to GetVirtualFileAddress() as well, to avoid future confusion between VM address and real file container address if a function name starts with GetFile?</div>

<div>- Otherwise, any other idea on how to proceed?</div>
<div><br></div><div>I might have misunderstood so don't hesitate to tell me if I'm totally wrong!</div><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Aug 24, 2013 at 3:33 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Actually this one is not correct. The m_file_offset is the offset of the PECOFF file within the file itself. So m_file_offset should be zero for all files that aren't in containers (like universal files on Darwin that contain multiple architecture slices, or .o files within a BSD archive (.a file)).<br>



<div><br>
<br>
On Aug 23, 2013, at 10:10 AM, Virgile Bello <<a href="mailto:virgile.bello@gmail.com" target="_blank">virgile.bello@gmail.com</a>> wrote:<br>
<br>
</div><div><div>> File offset is not set properly in PECOFF.<br>
><br>
> <a href="http://llvm-reviews.chandlerc.com/D1488" target="_blank">http://llvm-reviews.chandlerc.com/D1488</a><br>
><br>
> Files:<br>
>  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp<br>
><br>
> Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp<br>
> ===================================================================<br>
> --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp<br>
> +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp<br>
> @@ -434,6 +434,8 @@<br>
>                     m_coff_header_opt.data_dirs[i].vmaddr = m_data.GetU32(offset_ptr);<br>
>                     m_coff_header_opt.data_dirs[i].vmsize = m_data.GetU32(offset_ptr);<br>
>                 }<br>
> +<br>
> +                m_file_offset = m_coff_header_opt.image_base;<br>
>             }<br>
>         }<br>
>     }<br>
</div></div><div><div>> <D1488.1.patch>_______________________________________________<br>
> lldb-commits mailing list<br>
> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
<br>
</div></div></blockquote></div><br></div></div>