@@ -559,11 +559,8 @@ static bool GetOsFromOSABI(unsigned char osabi_byte,
559559// / Read the bytes for the section headers from the ELF object file data.
560560static DataExtractor GetSectionHeadersFromELFData (
561561 const elf::ELFHeader &header, const DataExtractor &object_data) {
562- DataExtractor sh_data;
563- const elf_off sh_offset = header.e_shoff ;
564- const size_t sh_size = header.GetSectionHeaderByteSize ();
565- sh_data.SetData (object_data, sh_offset, sh_size);
566- return sh_data;
562+ return DataExtractor (object_data, header.e_shoff ,
563+ header.GetSectionHeaderByteSize ());;
567564}
568565
569566// / Read the section data bytes for the section from the ELF object file data.
@@ -1511,8 +1508,17 @@ size_t ObjectFileELF::GetSectionHeaderInfo(const elf::ELFHeader &header,
15111508 // SHT_NULL sections if we have more than 1. The first entry in the section
15121509 // headers should always be a SHT_NULL section, but none of the others should
15131510 // be.
1514- if (section_headers.size () > 1 && section_headers[1 ].sh_type == SHT_NULL)
1515- section_headers.erase (section_headers.begin () + 1 );
1511+ if (section_headers.size () > 1 && section_headers[1 ].sh_type == SHT_NULL) {
1512+ uint64_t null_count = std::count_if (section_headers.begin (),
1513+ section_headers.end (),
1514+ [](const ELFSectionHeaderInfo &sh){
1515+ return sh.sh_type == SHT_NULL;
1516+ });
1517+ if (null_count == section_headers.size ()) {
1518+ // Keep only 1 SHT_NULL section if they were all SHT_NULL types.
1519+ section_headers.erase (section_headers.begin () + 1 );
1520+ }
1521+ }
15161522
15171523 const unsigned strtab_idx = header.e_shstrndx ;
15181524 if (strtab_idx && strtab_idx < section_headers.size ()) {
@@ -3861,11 +3867,10 @@ DataExtractor ObjectFileELF::GetSectionData(const elf::ELFSectionHeader &sh) {
38613867 // We have a ELF file in process memory, read the program header data from
38623868 // the process.
38633869 if (ProcessSP process_sp = m_process_wp.lock ()) {
3864- const addr_t data_addr = m_memory_addr + sh.sh_offset ;
3865- if (DataBufferSP data_sp = ReadMemory (process_sp, data_addr, sh.sh_size )) {
3866- data = DataExtractor (data_sp, GetByteOrder (), GetAddressByteSize ());
3867- if (data.GetByteSize () == sh.sh_size )
3868- return data;
3870+ const addr_t addr = m_memory_addr + sh.sh_offset ;
3871+ if (DataBufferSP data_sp = ReadMemory (process_sp, addr, sh.sh_size )) {
3872+ if (data_sp->GetByteSize () == sh.sh_size )
3873+ return DataExtractor (data_sp, GetByteOrder (), GetAddressByteSize ());
38693874 }
38703875 }
38713876 }
0 commit comments