diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2013-06-14 16:39:36 +0100 |
---|---|---|
committer | Ian Jackson <Ian.Jackson@eu.citrix.com> | 2013-06-14 16:39:36 +0100 |
commit | 66fe2726fe8492676f9970b9c2c511bce6186ece (patch) | |
tree | 702597668feac7320db2beb7bbc575de8fbf4a57 /xen/common | |
parent | 39bf7b9d0ae534491745e54df5232127c0bddaf1 (diff) | |
download | xen-66fe2726fe8492676f9970b9c2c511bce6186ece.tar.gz xen-66fe2726fe8492676f9970b9c2c511bce6186ece.tar.bz2 xen-66fe2726fe8492676f9970b9c2c511bce6186ece.zip |
libelf: abolish obsolete macros
Abolish ELF_PTRVAL_[CONST_]{CHAR,VOID}; change uses to elf_ptrval.
Abolish ELF_HANDLE_DECL_NONCONST; change uses to ELF_HANDLE_DECL.
Abolish ELF_OBSOLETE_VOIDP_CAST; simply remove all uses.
No functional change. (Verified by diffing assembler output.)
This is part of the fix to a security issue, XSA-55.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
v2: New patch.
Diffstat (limited to 'xen/common')
-rw-r--r-- | xen/common/libelf/libelf-dominfo.c | 6 | ||||
-rw-r--r-- | xen/common/libelf/libelf-loader.c | 24 | ||||
-rw-r--r-- | xen/common/libelf/libelf-tools.c | 24 |
3 files changed, 27 insertions, 27 deletions
diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c index 8ca2a33a8f..e79b339c84 100644 --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -220,8 +220,8 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, static unsigned elf_xen_parse_notes(struct elf_binary *elf, struct elf_dom_parms *parms, - ELF_PTRVAL_CONST_VOID start, - ELF_PTRVAL_CONST_VOID end, + elf_ptrval start, + elf_ptrval end, unsigned *total_note_count) { unsigned xen_elfnotes = 0; @@ -258,7 +258,7 @@ static unsigned elf_xen_parse_notes(struct elf_binary *elf, elf_errorstatus elf_xen_parse_guest_info(struct elf_binary *elf, struct elf_dom_parms *parms) { - ELF_PTRVAL_CONST_CHAR h; + elf_ptrval h; unsigned char name[32], value[128]; unsigned len; diff --git a/xen/common/libelf/libelf-loader.c b/xen/common/libelf/libelf-loader.c index 47957aa8f2..c5e9141b68 100644 --- a/xen/common/libelf/libelf-loader.c +++ b/xen/common/libelf/libelf-loader.c @@ -118,7 +118,7 @@ void elf_set_log(struct elf_binary *elf, elf_log_callback *log_callback, } static elf_errorstatus elf_load_image(struct elf_binary *elf, - ELF_PTRVAL_VOID dst, ELF_PTRVAL_CONST_VOID src, + elf_ptrval dst, elf_ptrval src, uint64_t filesz, uint64_t memsz) { elf_memcpy_safe(elf, dst, src, filesz); @@ -132,7 +132,7 @@ void elf_set_verbose(struct elf_binary *elf) elf->verbose = 1; } -static elf_errorstatus elf_load_image(struct elf_binary *elf, ELF_PTRVAL_VOID dst, ELF_PTRVAL_CONST_VOID src, uint64_t filesz, uint64_t memsz) +static elf_errorstatus elf_load_image(struct elf_binary *elf, elf_ptrval dst, elf_ptrval src, uint64_t filesz, uint64_t memsz) { elf_errorstatus rc; if ( filesz > ULONG_MAX || memsz > ULONG_MAX ) @@ -187,12 +187,12 @@ void elf_parse_bsdsyms(struct elf_binary *elf, uint64_t pstart) static void elf_load_bsdsyms(struct elf_binary *elf) { - ELF_HANDLE_DECL_NONCONST(elf_ehdr) sym_ehdr; + ELF_HANDLE_DECL(elf_ehdr) sym_ehdr; unsigned long sz; - ELF_PTRVAL_VOID maxva; - ELF_PTRVAL_VOID symbase; - ELF_PTRVAL_VOID symtab_addr; - ELF_HANDLE_DECL_NONCONST(elf_shdr) shdr; + elf_ptrval maxva; + elf_ptrval symbase; + elf_ptrval symtab_addr; + ELF_HANDLE_DECL(elf_shdr) shdr; unsigned i, type; if ( !elf->bsd_symtab_pstart ) @@ -226,7 +226,7 @@ do { \ elf_memcpy_safe(elf, ELF_HANDLE_PTRVAL(shdr), ELF_IMAGE_BASE(elf) + elf_uval(elf, elf->ehdr, e_shoff), sz); - maxva = ELF_OBSOLETE_VOIDP_CAST elf_round_up(elf, (unsigned long)maxva + sz); + maxva = elf_round_up(elf, (unsigned long)maxva + sz); for ( i = 0; i < elf_shdr_count(elf); i++ ) { @@ -242,7 +242,7 @@ do { \ elf_memcpy_safe(elf, maxva, elf_section_start(elf, shdr), sz); /* Mangled to be based on ELF header location. */ elf_hdr_elm(elf, shdr, sh_offset, maxva - symtab_addr); - maxva = ELF_OBSOLETE_VOIDP_CAST elf_round_up(elf, (unsigned long)maxva + sz); + maxva = elf_round_up(elf, (unsigned long)maxva + sz); } old_shdr_p = ELF_HANDLE_PTRVAL(shdr); new_shdr_p = old_shdr_p + elf_uval(elf, elf->ehdr, e_shentsize); @@ -297,7 +297,7 @@ elf_errorstatus elf_load_binary(struct elf_binary *elf) { ELF_HANDLE_DECL(elf_phdr) phdr; uint64_t i, count, paddr, offset, filesz, memsz; - ELF_PTRVAL_VOID dest; + elf_ptrval dest; /* * Let bizarre ELFs write the output image up to twice; this * calculation is just to ensure our copying loop is no worse than @@ -334,7 +334,7 @@ elf_errorstatus elf_load_binary(struct elf_binary *elf) remain_allow_copy -= memsz; elf_msg(elf, "%s: phdr %" PRIu64 " at 0x%"ELF_PRPTRVAL" -> 0x%"ELF_PRPTRVAL"\n", - __func__, i, dest, (ELF_PTRVAL_VOID)(dest + filesz)); + __func__, i, dest, (elf_ptrval)(dest + filesz)); if ( elf_load_image(elf, dest, ELF_IMAGE_BASE(elf) + offset, filesz, memsz) != 0 ) return -1; } @@ -343,7 +343,7 @@ elf_errorstatus elf_load_binary(struct elf_binary *elf) return 0; } -ELF_PTRVAL_VOID elf_get_ptr(struct elf_binary *elf, unsigned long addr) +elf_ptrval elf_get_ptr(struct elf_binary *elf, unsigned long addr) { return ELF_REALPTR2PTRVAL(elf->dest_base) + addr - elf->pstart; } diff --git a/xen/common/libelf/libelf-tools.c b/xen/common/libelf/libelf-tools.c index ef13b0dd77..dae210e87b 100644 --- a/xen/common/libelf/libelf-tools.c +++ b/xen/common/libelf/libelf-tools.c @@ -171,7 +171,7 @@ ELF_HANDLE_DECL(elf_shdr) elf_shdr_by_name(struct elf_binary *elf, const char *n ELF_HANDLE_DECL(elf_shdr) elf_shdr_by_index(struct elf_binary *elf, unsigned index) { uint64_t count = elf_shdr_count(elf); - ELF_PTRVAL_CONST_VOID ptr; + elf_ptrval ptr; if ( index >= count ) return ELF_INVALID_HANDLE(elf_shdr); @@ -185,7 +185,7 @@ ELF_HANDLE_DECL(elf_shdr) elf_shdr_by_index(struct elf_binary *elf, unsigned ind ELF_HANDLE_DECL(elf_phdr) elf_phdr_by_index(struct elf_binary *elf, unsigned index) { uint64_t count = elf_uval(elf, elf->ehdr, e_phnum); - ELF_PTRVAL_CONST_VOID ptr; + elf_ptrval ptr; if ( index >= count ) return ELF_INVALID_HANDLE(elf_phdr); @@ -233,24 +233,24 @@ const char *elf_strfmt(struct elf_binary *elf, elf_ptrval start) return str; } -ELF_PTRVAL_CONST_VOID elf_section_start(struct elf_binary *elf, ELF_HANDLE_DECL(elf_shdr) shdr) +elf_ptrval elf_section_start(struct elf_binary *elf, ELF_HANDLE_DECL(elf_shdr) shdr) { return ELF_IMAGE_BASE(elf) + elf_uval(elf, shdr, sh_offset); } -ELF_PTRVAL_CONST_VOID elf_section_end(struct elf_binary *elf, ELF_HANDLE_DECL(elf_shdr) shdr) +elf_ptrval elf_section_end(struct elf_binary *elf, ELF_HANDLE_DECL(elf_shdr) shdr) { return ELF_IMAGE_BASE(elf) + elf_uval(elf, shdr, sh_offset) + elf_uval(elf, shdr, sh_size); } -ELF_PTRVAL_CONST_VOID elf_segment_start(struct elf_binary *elf, ELF_HANDLE_DECL(elf_phdr) phdr) +elf_ptrval elf_segment_start(struct elf_binary *elf, ELF_HANDLE_DECL(elf_phdr) phdr) { return ELF_IMAGE_BASE(elf) + elf_uval(elf, phdr, p_offset); } -ELF_PTRVAL_CONST_VOID elf_segment_end(struct elf_binary *elf, ELF_HANDLE_DECL(elf_phdr) phdr) +elf_ptrval elf_segment_end(struct elf_binary *elf, ELF_HANDLE_DECL(elf_phdr) phdr) { return ELF_IMAGE_BASE(elf) + elf_uval(elf, phdr, p_offset) + elf_uval(elf, phdr, p_filesz); @@ -258,8 +258,8 @@ ELF_PTRVAL_CONST_VOID elf_segment_end(struct elf_binary *elf, ELF_HANDLE_DECL(el ELF_HANDLE_DECL(elf_sym) elf_sym_by_name(struct elf_binary *elf, const char *symbol) { - ELF_PTRVAL_CONST_VOID ptr = elf_section_start(elf, elf->sym_tab); - ELF_PTRVAL_CONST_VOID end = elf_section_end(elf, elf->sym_tab); + elf_ptrval ptr = elf_section_start(elf, elf->sym_tab); + elf_ptrval end = elf_section_end(elf, elf->sym_tab); ELF_HANDLE_DECL(elf_sym) sym; uint64_t info, name; const char *sym_name; @@ -283,7 +283,7 @@ ELF_HANDLE_DECL(elf_sym) elf_sym_by_name(struct elf_binary *elf, const char *sym ELF_HANDLE_DECL(elf_sym) elf_sym_by_index(struct elf_binary *elf, unsigned index) { - ELF_PTRVAL_CONST_VOID ptr = elf_section_start(elf, elf->sym_tab); + elf_ptrval ptr = elf_section_start(elf, elf->sym_tab); ELF_HANDLE_DECL(elf_sym) sym; sym = ELF_MAKE_HANDLE(elf_sym, ptr + index * elf_size(elf, sym)); @@ -295,7 +295,7 @@ const char *elf_note_name(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note return elf_strval(elf, ELF_HANDLE_PTRVAL(note) + elf_size(elf, note)); } -ELF_PTRVAL_CONST_VOID elf_note_desc(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note) +elf_ptrval elf_note_desc(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note) { unsigned namesz = (elf_uval(elf, note, namesz) + 3) & ~3; @@ -304,7 +304,7 @@ ELF_PTRVAL_CONST_VOID elf_note_desc(struct elf_binary *elf, ELF_HANDLE_DECL(elf_ uint64_t elf_note_numeric(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note) { - ELF_PTRVAL_CONST_VOID desc = elf_note_desc(elf, note); + elf_ptrval desc = elf_note_desc(elf, note); unsigned descsz = elf_uval(elf, note, descsz); switch (descsz) @@ -322,7 +322,7 @@ uint64_t elf_note_numeric(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note uint64_t elf_note_numeric_array(struct elf_binary *elf, ELF_HANDLE_DECL(elf_note) note, unsigned int unitsz, unsigned int idx) { - ELF_PTRVAL_CONST_VOID desc = elf_note_desc(elf, note); + elf_ptrval desc = elf_note_desc(elf, note); unsigned descsz = elf_uval(elf, note, descsz); if ( descsz % unitsz || idx >= descsz / unitsz ) |