elf_object.cc (5090:ac0d2ccc9c3b) | elf_object.cc (5143:4207b1d8b161) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 162 unchanged lines hidden (view full) --- 171 result->_programHeaderTable = 0; 172 for(int hdrnum = 0; hdrnum < result->_programHeaderCount; hdrnum++) 173 { 174 gelf_getphdr(elf, hdrnum, &phdr); 175 //Check if we've found the segment with the headers in it 176 if(phdr.p_offset <= e_phoff && 177 phdr.p_offset + phdr.p_filesz > e_phoff) 178 { | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 162 unchanged lines hidden (view full) --- 171 result->_programHeaderTable = 0; 172 for(int hdrnum = 0; hdrnum < result->_programHeaderCount; hdrnum++) 173 { 174 gelf_getphdr(elf, hdrnum, &phdr); 175 //Check if we've found the segment with the headers in it 176 if(phdr.p_offset <= e_phoff && 177 phdr.p_offset + phdr.p_filesz > e_phoff) 178 { |
179 result->_programHeaderTable = phdr.p_vaddr + e_phoff; | 179 result->_programHeaderTable = phdr.p_paddr + e_phoff; |
180 break; 181 } 182 } 183 } 184 else 185 result->_programHeaderTable = 0; 186 187 --- 68 unchanged lines hidden (view full) --- 256 panic("gelf_getphdr failed for segment %d.", i); 257 } 258 259 // for now we don't care about non-loadable segments 260 if (!(phdr.p_type & PT_LOAD)) 261 continue; 262 263 // Check to see if this segment contains the bss section. | 180 break; 181 } 182 } 183 } 184 else 185 result->_programHeaderTable = 0; 186 187 --- 68 unchanged lines hidden (view full) --- 256 panic("gelf_getphdr failed for segment %d.", i); 257 } 258 259 // for now we don't care about non-loadable segments 260 if (!(phdr.p_type & PT_LOAD)) 261 continue; 262 263 // Check to see if this segment contains the bss section. |
264 if (phdr.p_vaddr <= bssSecStart && 265 phdr.p_vaddr + phdr.p_memsz > bssSecStart && | 264 if (phdr.p_paddr <= bssSecStart && 265 phdr.p_paddr + phdr.p_memsz > bssSecStart && |
266 phdr.p_memsz - phdr.p_filesz > 0) { | 266 phdr.p_memsz - phdr.p_filesz > 0) { |
267 bss.baseAddr = phdr.p_vaddr + phdr.p_filesz; | 267 bss.baseAddr = phdr.p_paddr + phdr.p_filesz; |
268 bss.size = phdr.p_memsz - phdr.p_filesz; 269 bss.fileImage = NULL; 270 } 271 272 // Check to see if this is the text or data segment | 268 bss.size = phdr.p_memsz - phdr.p_filesz; 269 bss.fileImage = NULL; 270 } 271 272 // Check to see if this is the text or data segment |
273 if (phdr.p_vaddr <= textSecStart && 274 phdr.p_vaddr + phdr.p_filesz > textSecStart) { 275 text.baseAddr = phdr.p_vaddr; | 273 if (phdr.p_paddr <= textSecStart && 274 phdr.p_paddr + phdr.p_filesz > textSecStart) { 275 text.baseAddr = phdr.p_paddr; |
276 text.size = phdr.p_filesz; 277 text.fileImage = fileData + phdr.p_offset; | 276 text.size = phdr.p_filesz; 277 text.fileImage = fileData + phdr.p_offset; |
278 } else if (phdr.p_vaddr <= dataSecStart && 279 phdr.p_vaddr + phdr.p_filesz > dataSecStart) { 280 data.baseAddr = phdr.p_vaddr; | 278 } else if (phdr.p_paddr <= dataSecStart && 279 phdr.p_paddr + phdr.p_filesz > dataSecStart) { 280 data.baseAddr = phdr.p_paddr; |
281 data.size = phdr.p_filesz; 282 data.fileImage = fileData + phdr.p_offset; 283 } else { 284 Segment extra; | 281 data.size = phdr.p_filesz; 282 data.fileImage = fileData + phdr.p_offset; 283 } else { 284 Segment extra; |
285 extra.baseAddr = phdr.p_vaddr; | 285 extra.baseAddr = phdr.p_paddr; |
286 extra.size = phdr.p_filesz; 287 extra.fileImage = fileData + phdr.p_offset; 288 extraSegments.push_back(extra); 289 } 290 } 291 292 // should have found at least one loadable segment 293 assert(text.size != 0); --- 139 unchanged lines hidden --- | 286 extra.size = phdr.p_filesz; 287 extra.fileImage = fileData + phdr.p_offset; 288 extraSegments.push_back(extra); 289 } 290 } 291 292 // should have found at least one loadable segment 293 assert(text.size != 0); --- 139 unchanged lines hidden --- |