@ -91,7 +91,7 @@ int ElfMemImage::GetNumSymbols() const {
return 0 ;
return 0 ;
}
}
// See http://www.caldera.com/developers/gabi/latest/ch5.dynamic.html#hash
// See http://www.caldera.com/developers/gabi/latest/ch5.dynamic.html#hash
return hash_ [ 1 ] ;
return static_cast < int > ( hash_ [ 1 ] ) ;
}
}
const ElfW ( Sym ) * ElfMemImage : : GetDynsym ( int index ) const {
const ElfW ( Sym ) * ElfMemImage : : GetDynsym ( int index ) const {
@ -105,11 +105,9 @@ const ElfW(Versym) *ElfMemImage::GetVersym(int index) const {
}
}
const ElfW ( Phdr ) * ElfMemImage : : GetPhdr ( int index ) const {
const ElfW ( Phdr ) * ElfMemImage : : GetPhdr ( int index ) const {
ABSL_RAW_CHECK ( index < ehdr_ - > e_phnum , " index out of range " ) ;
ABSL_RAW_CHECK ( index > = 0 & & index < ehdr_ - > e_phnum , " index out of range " ) ;
return GetTableElement < ElfW ( Phdr ) > ( ehdr_ ,
return GetTableElement < ElfW ( Phdr ) > ( ehdr_ , ehdr_ - > e_phoff , ehdr_ - > e_phentsize ,
ehdr_ - > e_phoff ,
static_cast < size_t > ( index ) ) ;
ehdr_ - > e_phentsize ,
index ) ;
}
}
const char * ElfMemImage : : GetDynstr ( ElfW ( Word ) offset ) const {
const char * ElfMemImage : : GetDynstr ( ElfW ( Word ) offset ) const {
@ -159,7 +157,8 @@ void ElfMemImage::Init(const void *base) {
hash_ = nullptr ;
hash_ = nullptr ;
strsize_ = 0 ;
strsize_ = 0 ;
verdefnum_ = 0 ;
verdefnum_ = 0 ;
link_base_ = ~ 0L ; // Sentinel: PT_LOAD .p_vaddr can't possibly be this.
// Sentinel: PT_LOAD .p_vaddr can't possibly be this.
link_base_ = ~ ElfW ( Addr ) { 0 } ; // NOLINT(readability/braces)
if ( ! base ) {
if ( ! base ) {
return ;
return ;
}
}
@ -218,11 +217,11 @@ void ElfMemImage::Init(const void *base) {
}
}
ptrdiff_t relocation =
ptrdiff_t relocation =
base_as_char - reinterpret_cast < const char * > ( link_base_ ) ;
base_as_char - reinterpret_cast < const char * > ( link_base_ ) ;
ElfW ( Dyn ) * dynamic_entry =
ElfW ( Dyn ) * dynamic_entry = reinterpret_cast < ElfW ( Dyn ) * > (
reinterpret_cast < ElfW ( Dyn ) * > ( dynamic_program_header - > p_vaddr +
static_cast < intptr_t > ( dynamic_program_header - > p_vaddr ) + relocation ) ;
relocation ) ;
for ( ; dynamic_entry - > d_tag ! = DT_NULL ; + + dynamic_entry ) {
for ( ; dynamic_entry - > d_tag ! = DT_NULL ; + + dynamic_entry ) {
const auto value = dynamic_entry - > d_un . d_val + relocation ;
const auto value =
static_cast < intptr_t > ( dynamic_entry - > d_un . d_val ) + relocation ;
switch ( dynamic_entry - > d_tag ) {
switch ( dynamic_entry - > d_tag ) {
case DT_HASH :
case DT_HASH :
hash_ = reinterpret_cast < ElfW ( Word ) * > ( value ) ;
hash_ = reinterpret_cast < ElfW ( Word ) * > ( value ) ;
@ -240,10 +239,10 @@ void ElfMemImage::Init(const void *base) {
verdef_ = reinterpret_cast < ElfW ( Verdef ) * > ( value ) ;
verdef_ = reinterpret_cast < ElfW ( Verdef ) * > ( value ) ;
break ;
break ;
case DT_VERDEFNUM :
case DT_VERDEFNUM :
verdefnum_ = dynamic_entry - > d_un . d_val ;
verdefnum_ = static_cast < size_t > ( dynamic_entry - > d_un . d_val ) ;
break ;
break ;
case DT_STRSZ :
case DT_STRSZ :
strsize_ = dynamic_entry - > d_un . d_val ;
strsize_ = static_cast < size_t > ( dynamic_entry - > d_un . d_val ) ;
break ;
break ;
default :
default :
// Unrecognized entries explicitly ignored.
// Unrecognized entries explicitly ignored.