]> git.pld-linux.org Git - packages/elfutils.git/blob - elfutils-fixes.patch
- alignment fixes from Fedora
[packages/elfutils.git] / elfutils-fixes.patch
1 --- elfutils-0.137/libdwfl/ChangeLog
2 +++ elfutils-0.137/libdwfl/ChangeLog
3 @@ -1,3 +1,12 @@
4 +2008-08-28  Roland McGrath  <roland@redhat.com>
5 +
6 +       * segment.c (reify_segments): Fix last change.
7 +
8 +2008-08-27  Roland McGrath  <roland@redhat.com>
9 +
10 +       * linux-proc-maps.c (read_proc_memory): Return 0 for EINVAL or EPERM
11 +       failure from pread64.
12 +
13  2008-08-26  Roland McGrath  <roland@redhat.com>
14  
15         * segment.c (reify_segments): Insert a trailing segment for a module
16 --- elfutils-0.137/libdwfl/linux-proc-maps.c
17 +++ elfutils-0.137/libdwfl/linux-proc-maps.c
18 @@ -267,6 +267,9 @@ read_proc_memory (void *arg, void *data,
19  {
20    const int fd = *(const int *) arg;
21    ssize_t nread = pread64 (fd, data, maxread, (off64_t) address);
22 +  /* Some kernels don't actually let us do this read, ignore those errors.  */
23 +  if (nread < 0 && (errno == EINVAL || errno == EPERM))
24 +    return 0;
25    if (nread > 0 && (size_t) nread < minread)
26      nread = 0;
27    return nread;
28 --- elfutils-0.137/libdwfl/segment.c
29 +++ elfutils-0.137/libdwfl/segment.c
30 @@ -175,9 +175,17 @@ reify_segments (Dwfl *dwfl)
31               return true;
32             ++idx;
33           }
34 +       else if (dwfl->lookup_addr[idx] < start)
35 +         {
36 +           /* The module starts past the end of this segment.
37 +              Add a new one.  */
38 +           if (unlikely (insert (dwfl, idx + 1, start, end, -1)))
39 +             return true;
40 +           ++idx;
41 +         }
42  
43 -       if (((size_t) idx + 1 == dwfl->lookup_elts
44 -            || end < dwfl->lookup_addr[idx + 1])
45 +       if ((size_t) idx + 1 < dwfl->lookup_elts
46 +           && end < dwfl->lookup_addr[idx + 1]
47             /* The module ends in the middle of this segment.  Split it.  */
48             && unlikely (insert (dwfl, idx + 1,
49                                  end, dwfl->lookup_addr[idx + 1], -1)))
50 --- elfutils-0.137/libelf/ChangeLog
51 +++ elfutils-0.137/libelf/ChangeLog
52 @@ -1,3 +1,9 @@
53 +2008-08-27  Roland McGrath  <roland@redhat.com>
54 +
55 +       * elf_begin.c (get_shnum): Avoid misaligned reads for matching endian.
56 +
57 +       * libelfP.h [!ALLOW_UNALIGNED] (__libelf_type_align): Fix CLASS index.
58 +
59  2008-08-25  Roland McGrath  <roland@redhat.com>
60  
61         * Makefile.am (libelf_so_LDLIBS): New variable.
62 --- elfutils-0.137/libelf/elf_begin.c
63 +++ elfutils-0.137/libelf/elf_begin.c
64 @@ -110,8 +110,14 @@ get_shnum (void *map_address, unsigned c
65    } ehdr_mem;
66    bool is32 = e_ident[EI_CLASS] == ELFCLASS32;
67  
68 +  // e_shnum shoff
69 +
70    /* Make the ELF header available.  */
71 -  if (e_ident[EI_DATA] == MY_ELFDATA)
72 +  if (e_ident[EI_DATA] == MY_ELFDATA
73 +      && (ALLOW_UNALIGNED
74 +         || (((size_t) e_ident
75 +              & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr))
76 +                 - 1)) == 0)))
77      ehdr.p = e_ident;
78    else
79      {
80 @@ -130,8 +136,11 @@ get_shnum (void *map_address, unsigned c
81           else
82             memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr));
83  
84 -         CONVERT (ehdr_mem.e32.e_shnum);
85 -         CONVERT (ehdr_mem.e32.e_shoff);
86 +         if (e_ident[EI_DATA] != MY_ELFDATA)
87 +           {
88 +             CONVERT (ehdr_mem.e32.e_shnum);
89 +             CONVERT (ehdr_mem.e32.e_shoff);
90 +           }
91         }
92        else
93         {
94 @@ -143,8 +152,11 @@ get_shnum (void *map_address, unsigned c
95           else
96             memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr));
97  
98 -         CONVERT (ehdr_mem.e64.e_shnum);
99 -         CONVERT (ehdr_mem.e64.e_shoff);
100 +         if (e_ident[EI_DATA] != MY_ELFDATA)
101 +           {
102 +             CONVERT (ehdr_mem.e64.e_shnum);
103 +             CONVERT (ehdr_mem.e64.e_shoff);
104 +           }
105         }
106      }
107  
108 --- elfutils-0.137/libelf/libelfP.h
109 +++ elfutils-0.137/libelf/libelfP.h
110 @@ -460,7 +460,7 @@ extern const uint_fast8_t __libelf_type_
111     version, binary class, and type. */
112  extern const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden;
113  # define __libelf_type_align(class, type)      \
114 -    (__libelf_type_aligns[LIBELF_EV_IDX][class][type] ?: 1)
115 +    (__libelf_type_aligns[LIBELF_EV_IDX][class - 1][type] ?: 1)
116  #else
117  # define __libelf_type_align(class, type)      1
118  #endif
This page took 0.038519 seconds and 3 git commands to generate.