elf_object.cc (11391:484c04261226) | elf_object.cc (11392:5967db4cff04) |
---|---|
1/* 2 * Copyright (c) 2011-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 382 unchanged lines hidden (view full) --- 391 392 elf_end(elf); 393 394 // We will actually read the sections when we need to load them 395} 396 397 398bool | 1/* 2 * Copyright (c) 2011-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 382 unchanged lines hidden (view full) --- 391 392 elf_end(elf); 393 394 // We will actually read the sections when we need to load them 395} 396 397 398bool |
399ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding, Addr mask) | 399ElfObject::loadSomeSymbols(SymbolTable *symtab, int binding, Addr mask, 400 Addr base, Addr offset) |
400{ 401 if (!symtab) 402 return false; 403 404 // check that header matches library version 405 if (elf_version(EV_CURRENT) == EV_NONE) 406 panic("wrong elf version number!"); 407 --- 19 unchanged lines hidden (view full) --- 427 428 // loop through all the symbols, only loading global ones 429 for (int i = 0; i < count; ++i) { 430 GElf_Sym sym; 431 gelf_getsym(data, i, &sym); 432 if (GELF_ST_BIND(sym.st_info) == binding) { 433 char *sym_name = elf_strptr(elf, shdr.sh_link, sym.st_name); 434 if (sym_name && sym_name[0] != '$') { | 401{ 402 if (!symtab) 403 return false; 404 405 // check that header matches library version 406 if (elf_version(EV_CURRENT) == EV_NONE) 407 panic("wrong elf version number!"); 408 --- 19 unchanged lines hidden (view full) --- 428 429 // loop through all the symbols, only loading global ones 430 for (int i = 0; i < count; ++i) { 431 GElf_Sym sym; 432 gelf_getsym(data, i, &sym); 433 if (GELF_ST_BIND(sym.st_info) == binding) { 434 char *sym_name = elf_strptr(elf, shdr.sh_link, sym.st_name); 435 if (sym_name && sym_name[0] != '$') { |
435 DPRINTF(Loader, "Symbol: %-40s value %#x\n", 436 sym_name, sym.st_value); 437 symtab->insert(sym.st_value & mask, sym_name); | 436 Addr value = sym.st_value - base + offset; 437 if (symtab->insert(value & mask, sym_name)) { 438 DPRINTF(Loader, "Symbol: %-40s value %#x\n", 439 sym_name, value); 440 } |
438 } 439 } 440 } 441 } 442 ++sec_idx; 443 section = elf_getscn(elf, sec_idx); 444 } 445 446 elf_end(elf); 447 448 return found; 449} 450 451bool | 441 } 442 } 443 } 444 } 445 ++sec_idx; 446 section = elf_getscn(elf, sec_idx); 447 } 448 449 elf_end(elf); 450 451 return found; 452} 453 454bool |
452ElfObject::loadGlobalSymbols(SymbolTable *symtab, Addr addr_mask) | 455ElfObject::loadAllSymbols(SymbolTable *symtab, Addr base, Addr offset, 456 Addr addr_mask) |
453{ | 457{ |
454 return loadSomeSymbols(symtab, STB_GLOBAL, addr_mask); | 458 return (loadGlobalSymbols(symtab, base, offset, addr_mask) && 459 loadLocalSymbols(symtab, base, offset, addr_mask) && 460 loadWeakSymbols(symtab, base, offset, addr_mask)); |
455} 456 457bool | 461} 462 463bool |
458ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addr_mask) | 464ElfObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset, 465 Addr addr_mask) |
459{ | 466{ |
460 bool found_local = loadSomeSymbols(symtab, STB_LOCAL, addr_mask); 461 bool found_weak = loadSomeSymbols(symtab, STB_WEAK, addr_mask); 462 return found_local || found_weak; | 467 if (interpreter) { 468 interpreter->loadSomeSymbols(symtab, STB_GLOBAL, addr_mask, 469 base, offset); 470 } 471 return loadSomeSymbols(symtab, STB_GLOBAL, addr_mask, base, offset); |
463} 464 465bool | 472} 473 474bool |
466ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr addr_mask) | 475ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset, 476 Addr addr_mask) |
467{ | 477{ |
468 return loadSomeSymbols(symtab, STB_WEAK, addr_mask); | 478 if (interpreter) { 479 interpreter->loadSomeSymbols(symtab, STB_LOCAL, addr_mask, 480 base, offset); 481 } 482 return loadSomeSymbols(symtab, STB_LOCAL, addr_mask, base, offset); |
469} 470 471bool | 483} 484 485bool |
486ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr base, Addr offset, 487 Addr addr_mask) 488{ 489 if (interpreter) { 490 interpreter->loadSomeSymbols(symtab, STB_WEAK, addr_mask, 491 base, offset); 492 } 493 return loadSomeSymbols(symtab, STB_WEAK, addr_mask, base, offset); 494} 495 496bool |
|
472ElfObject::loadSections(PortProxy& mem_proxy, Addr addr_mask, Addr offset) 473{ 474 if (!ObjectFile::loadSections(mem_proxy, addr_mask, offset)) 475 return false; 476 477 for (auto seg : extraSegments) { 478 if (!loadSection(&seg, mem_proxy, addr_mask, offset)) { 479 return false; --- 67 unchanged lines hidden --- | 497ElfObject::loadSections(PortProxy& mem_proxy, Addr addr_mask, Addr offset) 498{ 499 if (!ObjectFile::loadSections(mem_proxy, addr_mask, offset)) 500 return false; 501 502 for (auto seg : extraSegments) { 503 if (!loadSection(&seg, mem_proxy, addr_mask, offset)) { 504 return false; --- 67 unchanged lines hidden --- |