X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Flttng-elf.cpp;h=be1db0250ac02bae4af5cba422c52c3cb41a8132;hb=HEAD;hp=108686042db85ae66fb46b9383754be8ac7c5bdc;hpb=cd9adb8b829564212158943a0d279bb35322ab30;p=lttng-tools.git diff --git a/src/common/lttng-elf.cpp b/src/common/lttng-elf.cpp index 108686042..8094b4967 100644 --- a/src/common/lttng-elf.cpp +++ b/src/common/lttng-elf.cpp @@ -33,7 +33,7 @@ #define NOTE_STAPSDT_SECTION_NAME ".note.stapsdt" #define NOTE_STAPSDT_NAME "stapsdt" #define NOTE_STAPSDT_TYPE 3 -#define MAX_SECTION_DATA_SIZE 512 * 1024 * 1024 +#define MAX_SECTION_DATA_SIZE (512 * 1024 * 1024) #if BYTE_ORDER == LITTLE_ENDIAN #define NATIVE_ELF_ENDIANNESS ELFDATA2LSB @@ -41,25 +41,25 @@ #define NATIVE_ELF_ENDIANNESS ELFDATA2MSB #endif -#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t) x) + 3) & ~0x03) - -#define bswap(x) \ - do { \ - switch (sizeof(x)) { \ - case 8: \ - x = be64toh((uint64_t) x); \ - break; \ - case 4: \ - x = be32toh((uint32_t) x); \ - break; \ - case 2: \ - x = be16toh((uint16_t) x); \ - break; \ - case 1: \ - break; \ - default: \ - abort(); \ - } \ +#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t) (x)) + 3) & ~0x03) + +#define bswap(x) \ + do { \ + switch (sizeof(x)) { \ + case 8: \ + (x) = be64toh((uint64_t) (x)); \ + break; \ + case 4: \ + (x) = be32toh((uint32_t) (x)); \ + break; \ + case 2: \ + (x) = be16toh((uint16_t) (x)); \ + break; \ + case 1: \ + break; \ + default: \ + abort(); \ + } \ } while (0) #define bswap_shdr(shdr) \ @@ -124,14 +124,14 @@ (dst_ehdr).e_shstrndx = (src_ehdr).e_shstrndx; \ } while (0) -#define copy_sym(src_sym, dst_sym) \ - do { \ - dst_sym.st_name = src_sym.st_name; \ - dst_sym.st_info = src_sym.st_info; \ - dst_sym.st_other = src_sym.st_other; \ - dst_sym.st_shndx = src_sym.st_shndx; \ - dst_sym.st_value = src_sym.st_value; \ - dst_sym.st_size = src_sym.st_size; \ +#define copy_sym(src_sym, dst_sym) \ + do { \ + (dst_sym).st_name = (src_sym).st_name; \ + (dst_sym).st_info = (src_sym).st_info; \ + (dst_sym).st_other = (src_sym).st_other; \ + (dst_sym).st_shndx = (src_sym).st_shndx; \ + (dst_sym).st_value = (src_sym).st_value; \ + (dst_sym).st_size = (src_sym).st_size; \ } while (0) #ifndef ELFCLASSNUM @@ -610,7 +610,7 @@ static int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf, for (i = 0; i < elf->ehdr->e_shnum; ++i) { bool name_equal; - int ret = lttng_elf_get_section_hdr(elf, i, section_hdr); + const int ret = lttng_elf_get_section_hdr(elf, i, section_hdr); if (ret) { break; @@ -823,10 +823,10 @@ int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset) /* Get the symbol at the current index. */ if (is_elf_32_bit(elf)) { - Elf32_Sym tmp = ((Elf32_Sym *) symbol_table_data)[sym_idx]; + const Elf32_Sym tmp = ((Elf32_Sym *) symbol_table_data)[sym_idx]; copy_sym(tmp, curr_sym); } else { - Elf64_Sym tmp = ((Elf64_Sym *) symbol_table_data)[sym_idx]; + const Elf64_Sym tmp = ((Elf64_Sym *) symbol_table_data)[sym_idx]; copy_sym(tmp, curr_sym); }