Changed return values of SectionHeaderIterator().next() to bswapAllFields() (#9014)

This commit is contained in:
ArtixFox 2021-06-08 23:02:12 +05:30 committed by GitHub
parent 38e233845e
commit 032204ffe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -479,18 +479,8 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {
if (self.elf_header.endian == native_endian) return shdr;
// Convert fields to native endianness.
return Elf64_Shdr{
.sh_name = @byteSwap(@TypeOf(shdr.sh_name), shdr.sh_name),
.sh_type = @byteSwap(@TypeOf(shdr.sh_type), shdr.sh_type),
.sh_flags = @byteSwap(@TypeOf(shdr.sh_flags), shdr.sh_flags),
.sh_addr = @byteSwap(@TypeOf(shdr.sh_addr), shdr.sh_addr),
.sh_offset = @byteSwap(@TypeOf(shdr.sh_offset), shdr.sh_offset),
.sh_size = @byteSwap(@TypeOf(shdr.sh_size), shdr.sh_size),
.sh_link = @byteSwap(@TypeOf(shdr.sh_link), shdr.sh_link),
.sh_info = @byteSwap(@TypeOf(shdr.sh_info), shdr.sh_info),
.sh_addralign = @byteSwap(@TypeOf(shdr.sh_addralign), shdr.sh_addralign),
.sh_entsize = @byteSwap(@TypeOf(shdr.sh_entsize), shdr.sh_entsize),
};
bswapAllFields(Elf64_Shdr, &shdr);
return shdr;
}
var shdr: Elf32_Shdr = undefined;
@ -501,18 +491,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type {
// ELF endianness does NOT match native endianness.
if (self.elf_header.endian != native_endian) {
// Convert fields to native endianness.
shdr = .{
.sh_name = @byteSwap(@TypeOf(shdr.sh_name), shdr.sh_name),
.sh_type = @byteSwap(@TypeOf(shdr.sh_type), shdr.sh_type),
.sh_flags = @byteSwap(@TypeOf(shdr.sh_flags), shdr.sh_flags),
.sh_addr = @byteSwap(@TypeOf(shdr.sh_addr), shdr.sh_addr),
.sh_offset = @byteSwap(@TypeOf(shdr.sh_offset), shdr.sh_offset),
.sh_size = @byteSwap(@TypeOf(shdr.sh_size), shdr.sh_size),
.sh_link = @byteSwap(@TypeOf(shdr.sh_link), shdr.sh_link),
.sh_info = @byteSwap(@TypeOf(shdr.sh_info), shdr.sh_info),
.sh_addralign = @byteSwap(@TypeOf(shdr.sh_addralign), shdr.sh_addralign),
.sh_entsize = @byteSwap(@TypeOf(shdr.sh_entsize), shdr.sh_entsize),
};
bswapAllFields(Elf32_Shdr, &shdr);
}
// Convert 32-bit header to 64-bit.