@@ -84,51 +84,43 @@ void DynamicLoaderStatic::LoadAllImagesAtFileAddresses() {
84
84
// Disable JIT for static dynamic loader targets
85
85
m_process->SetCanJIT (false );
86
86
87
+ Target &target = m_process->GetTarget ();
87
88
for (ModuleSP module_sp : module_list.Modules ()) {
88
89
if (module_sp) {
89
90
bool changed = false ;
91
+ bool no_load_addresses = true ;
92
+ // If this module has a section with a load address set in
93
+ // the target, assume all necessary work is already done. There
94
+ // may be sections without a load address set intentionally
95
+ // and we don't want to mutate that.
96
+ // For a module with no load addresses set, set the load addresses
97
+ // to slide == 0, the same as the file addresses, in the target.
90
98
ObjectFile *image_object_file = module_sp->GetObjectFile ();
91
99
if (image_object_file) {
92
100
SectionList *section_list = image_object_file->GetSectionList ();
93
101
if (section_list) {
94
- // All sections listed in the dyld image info structure will all
95
- // either be fixed up already, or they will all be off by a single
96
- // slide amount that is determined by finding the first segment that
97
- // is at file offset zero which also has bytes (a file size that is
98
- // greater than zero) in the object file.
99
-
100
- // Determine the slide amount (if any)
101
102
const size_t num_sections = section_list->GetSize ();
102
- size_t sect_idx = 0 ;
103
- for (sect_idx = 0 ; sect_idx < num_sections; ++sect_idx) {
104
- // Iterate through the object file sections to find the first
105
- // section that starts of file offset zero and that has bytes in
106
- // the file...
103
+ for (size_t sect_idx = 0 ; sect_idx < num_sections; ++sect_idx) {
107
104
SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
108
105
if (section_sp) {
109
- // If this section already has a load address set in the target,
110
- // don't re-set it to the file address. Something may have
111
- // set it to a more correct value already.
112
- if (m_process->GetTarget ()
113
- .GetSectionLoadList ()
114
- .GetSectionLoadAddress (section_sp) !=
115
- LLDB_INVALID_ADDRESS) {
116
- continue ;
106
+ if (target.GetSectionLoadList ().GetSectionLoadAddress (
107
+ section_sp) != LLDB_INVALID_ADDRESS) {
108
+ no_load_addresses = false ;
109
+ break ;
117
110
}
118
- if (m_process->GetTarget ().SetSectionLoadAddress (
119
- section_sp, section_sp->GetFileAddress ()))
120
- changed = true ;
121
111
}
122
112
}
123
113
}
124
114
}
115
+ if (no_load_addresses)
116
+ module_sp->SetLoadAddress (target, 0 , true /* value_is_offset*/ , changed);
125
117
126
118
if (changed)
127
119
loaded_module_list.AppendIfNeeded (module_sp);
128
120
}
129
121
}
130
122
131
- m_process-> GetTarget () .ModulesDidLoad (loaded_module_list);
123
+ target .ModulesDidLoad (loaded_module_list);
132
124
}
133
125
134
126
ThreadPlanSP
0 commit comments