1 2006-04-16 Jakub Bogusz <qboosh at pld-linux dot org>
3 * src/elflint.c (valid_e_machine) Add EM_ALPHA to valid machines.
4 (check_hash): Support hash bucket size of 8 on alpha and s390x.
5 (check_sections): Support arch-specific section flags.
6 * libelf/elf32_getshdr.c: Handle unaligned section header with same
8 * backends/alpha_init.c: Add register_name hook.
9 * backends/alpha_regs.c: New file.
10 * backends/Makefile.am: Add alpha_regs.c.
12 --- elfutils-0.116/src/elflint.c.orig 2005-11-26 10:28:00.000000000 +0100
13 +++ elfutils-0.116/src/elflint.c 2005-11-26 14:01:18.000000000 +0100
15 EM_68HC16, EM_68HC11, EM_68HC08, EM_68HC05, EM_SVX, EM_ST19, EM_VAX,
16 EM_CRIS, EM_JAVELIN, EM_FIREPATH, EM_ZSP, EM_MMIX, EM_HUANY, EM_PRISM,
17 EM_AVR, EM_FR30, EM_D10V, EM_D30V, EM_V850, EM_M32R, EM_MN10300,
18 - EM_MN10200, EM_PJ, EM_OPENRISC, EM_ARC_A5, EM_XTENSA
19 + EM_MN10200, EM_PJ, EM_OPENRISC, EM_ARC_A5, EM_XTENSA, EM_ALPHA
21 #define nvalid_e_machine \
22 (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
23 @@ -1664,6 +1664,16 @@
24 section [%2d] '%s': hash table not for dynamic symbol table\n"),
25 idx, section_name (ebl, idx));
28 + (ehdr->e_machine == EM_ALPHA) ||
29 + ((ehdr->e_machine == EM_S390) && (ehdr->e_ident[EI_CLASS] == ELFCLASS64));
32 + if (shdr->sh_entsize != 8) /* alpha and s390x use non-standard hash bucket size of 8 */
34 +section [%2d] '%s': entry size is not 8\n"),
35 + idx, section_name (ebl, idx));
37 if (shdr->sh_entsize != sizeof (Elf32_Word))
39 section [%2d] '%s': entry size does not match Elf32_Word\n"),
40 @@ -1681,8 +1691,15 @@
44 - Elf32_Word nbucket = ((Elf32_Word *) data->d_buf)[0];
45 - Elf32_Word nchain = ((Elf32_Word *) data->d_buf)[1];
46 + uint64_t nbucket, nchain;
49 + nbucket = ((Elf64_Xword *) data->d_buf)[0];
50 + nchain = ((Elf64_Xword *) data->d_buf)[1];
52 + nbucket = ((Elf32_Word *) data->d_buf)[0];
53 + nchain = ((Elf32_Word *) data->d_buf)[1];
56 if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize)
58 @@ -1694,29 +1711,41 @@
60 size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
62 - Elf32_Word *buf, *end;
66 if (nchain < symshdr->sh_size / symshdr->sh_entsize)
67 ERROR (gettext ("section [%2d] '%s': chain array not large enough\n"),
68 idx, section_name (ebl, idx));
71 + buf = ((Elf64_Xword *) data->d_buf) + 2;
72 + end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size);
74 buf = ((Elf32_Word *) data->d_buf) + 2;
75 end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size);
76 - for (cnt = 2; cnt < 2 + nbucket; ++cnt)
78 + for (cnt = 2; cnt < 2 + nbucket; ++cnt) {
81 - else if (*buf++ >= symsize)
82 + val = bighash ? *(Elf64_Xword *)buf : *(Elf32_Word *)buf;
85 section [%2d] '%s': hash bucket reference %zu out of bounds\n"),
86 idx, section_name (ebl, idx), cnt - 2);
87 + buf += bighash ? 8 : sizeof(Elf32_Word);
90 - for (; cnt < 2 + nbucket + nchain; ++cnt)
91 + for (; cnt < 2 + nbucket + nchain; ++cnt) {
94 - else if (*buf++ >= symsize)
95 + val = bighash ? *(Elf64_Xword *)buf : *(Elf32_Word *)buf;
98 section [%2d] '%s': hash chain reference %zu out of bounds\n"),
99 idx, section_name (ebl, idx), cnt - 2 - nbucket);
100 + buf += bighash ? 8 : sizeof(Elf32_Word);
105 @@ -2744,9 +2773,30 @@
106 cnt, section_name (ebl, cnt),
107 (int) shdr->sh_type);
109 -#define ALL_SH_FLAGS (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR | SHF_MERGE \
110 +#define GALL_SH_FLAGS (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR | SHF_MERGE \
111 | SHF_STRINGS | SHF_INFO_LINK | SHF_LINK_ORDER \
112 | SHF_OS_NONCONFORMING | SHF_GROUP | SHF_TLS)
113 + uint64_t ALL_SH_FLAGS = GALL_SH_FLAGS; /* generic */
114 + switch (ehdr->e_machine) {
116 + ALL_SH_FLAGS |= SHF_MIPS_GPREL | SHF_MIPS_MERGE | SHF_MIPS_ADDR |
117 + SHF_MIPS_STRINGS | SHF_MIPS_NOSTRIP | SHF_MIPS_LOCAL |
118 + SHF_MIPS_NAMES | SHF_MIPS_NODUPE;
121 + ALL_SH_FLAGS |= SHF_PARISC_SHORT | SHF_PARISC_HUGE | SHF_PARISC_SBP;
124 + ALL_SH_FLAGS |= SHF_ALPHA_GPREL;
127 + ALL_SH_FLAGS |= SHF_ARM_ENTRYSECT | SHF_ARM_COMDEF;
130 + ALL_SH_FLAGS |= SHF_IA_64_SHORT | SHF_IA_64_NORECOV;
134 if (shdr->sh_flags & ~ALL_SH_FLAGS)
135 ERROR (gettext ("section [%2zu] '%s' contains unknown flag(s)"
137 --- elfutils-0.119/libelf/elf32_getshdr.c.orig 2006-02-05 18:17:07.948304250 +0100
138 +++ elfutils-0.119/libelf/elf32_getshdr.c 2006-02-05 18:26:52.836857500 +0100
142 /* Now copy the data and at the same time convert the byte
144 + order, if needed. */
145 + if (ehdr->e_ident[EI_DATA] == MY_ELFDATA)
146 + memcpy (shdr, ((char*) elf->map_address + elf->start_offset + ehdr->e_shoff), size);
149 || (((uintptr_t) elf->map_address + elf->start_offset
152 CONVERT_TO (shdr[cnt].sh_addralign, notcvt[cnt].sh_addralign);
153 CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize);
157 else if (likely (elf->fildes != -1))
159 --- elfutils-0.120/backends/alpha_init.c.orig 2006-04-05 00:17:36.000000000 +0200
160 +++ elfutils-0.120/backends/alpha_init.c 2006-04-16 13:11:08.819218500 +0200
162 HOOK (eh, dynamic_tag_check);
163 HOOK (eh, reloc_simple_type);
164 HOOK (eh, return_value_location);
165 + HOOK (eh, register_name);
169 --- elfutils-0.120/backends/alpha_regs.c.orig 1970-01-01 01:00:00.000000000 +0100
170 +++ elfutils-0.120/backends/alpha_regs.c 2006-04-16 13:10:15.947914250 +0200
172 +/* Register names and numbers for ALPHA DWARF.
173 + Based on i386_regs.c, Copyright (C) 2005 Red Hat, Inc.
174 + This file is part of Red Hat elfutils.
176 + Red Hat elfutils is free software; you can redistribute it and/or modify
177 + it under the terms of the GNU General Public License as published by the
178 + Free Software Foundation; version 2 of the License.
180 + Red Hat elfutils is distributed in the hope that it will be useful, but
181 + WITHOUT ANY WARRANTY; without even the implied warranty of
182 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
183 + General Public License for more details.
185 + You should have received a copy of the GNU General Public License along
186 + with Red Hat elfutils; if not, write to the Free Software Foundation,
187 + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
189 + Red Hat elfutils is an included package of the Open Invention Network.
190 + An included package of the Open Invention Network is a package for which
191 + Open Invention Network licensees cross-license their patents. No patent
192 + license is granted, either expressly or impliedly, by designation as an
193 + included package. Should you wish to participate in the Open Invention
194 + Network licensing program, please visit www.openinventionnetwork.com
195 + <http://www.openinventionnetwork.com>. */
197 +#ifdef HAVE_CONFIG_H
198 +# include <config.h>
203 +#define BACKEND alpha_
204 +#include "libebl_CPU.h"
207 +alpha_register_name (Ebl *ebl __attribute__ ((unused)),
208 + int regno, char *name, size_t namelen,
209 + const char **prefix, const char **setname)
214 + if (regno < 0 || regno > 64 || namelen < 5)
219 + *setname = "integer";
220 + else if (regno < 64)
227 + static const char *alpharegs[] =
229 + "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
230 + "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6",
231 + "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
232 + "t10","t11","ra", "t12","at", "gp", "sp", "zero",
233 + "fv0","fv1","fs0","fs1","fs2","fs3","fs4","fs5",
234 + "fs6","fs7","ft0","ft1","ft2","ft3","ft4","ft5",
235 + "fa0","fa1","fa2","fa3","fa4","fa5","ft6","ft7",
236 + "ft8","ft9","ft10","ft11","ft12","ft13","ft14","fzero",
241 + strcpy(name, alpharegs[regno]);
242 + namelen = strlen(name);
253 --- elfutils-0.120/backends/Makefile.am.orig 2006-04-16 13:15:56.425192000 +0200
254 +++ elfutils-0.120/backends/Makefile.am 2006-04-16 13:28:26.928096250 +0200
256 libebl_ia64_pic_a_SOURCES = $(ia64_SRCS)
257 am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os)
259 -alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c
260 +alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c
261 libebl_alpha_pic_a_SOURCES = $(alpha_SRCS)
262 am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os)