@@ -325,6 +325,7 @@ bool ObjectFileXCOFF::SetLoadAddress(Target &target, lldb::addr_t value,
325
325
if (module_sp) {
326
326
size_t num_loaded_sections = 0 ;
327
327
SectionList *section_list = GetSectionList ();
328
+
328
329
if (section_list) {
329
330
const size_t num_sections = section_list->GetSize ();
330
331
size_t sect_idx = 0 ;
@@ -333,16 +334,19 @@ bool ObjectFileXCOFF::SetLoadAddress(Target &target, lldb::addr_t value,
333
334
// Iterate through the object file sections to find all of the sections
334
335
// that have SHF_ALLOC in their flag bits.
335
336
SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
336
- if (section_sp && !section_sp->IsThreadSpecific ()) {
337
- bool use_offset = false ;
338
- if (strcmp (section_sp->GetName ().AsCString (), " .text" ) == 0 ||
339
- strcmp (section_sp->GetName ().AsCString (), " .data" ) == 0 ||
340
- strcmp (section_sp->GetName ().AsCString (), " .bss" ) == 0 )
341
- use_offset = true ;
342
337
338
+ if (section_sp && !section_sp->IsThreadSpecific ()) {
339
+ addr_t load_addr = 0 ;
340
+ if (!value_is_offset)
341
+ load_addr = section_sp->GetFileAddress ();
342
+ else {
343
+ if (strcmp (section_sp->GetName ().AsCString (), " .text" ) == 0 )
344
+ load_addr = section_sp->GetFileOffset () + value;
345
+ else /* Other sections: data, bss, loader, dwline, dwinfo, dwabrev */
346
+ load_addr = section_sp->GetFileAddress () + value;
347
+ }
343
348
if (target.GetSectionLoadListPublic ().SetSectionLoadAddress (
344
- section_sp, (use_offset ?
345
- (section_sp->GetFileOffset () + value) : (section_sp->GetFileAddress () + value))))
349
+ section_sp, load_addr))
346
350
++num_loaded_sections;
347
351
}
348
352
}
0 commit comments