6 unsigned long elf_hash(const unsigned char *name
) {
11 h
= (h
<< 4) + *name
++;
12 if ((g
= h
& 0xF0000000))
21 unsigned long elf_gnu_hash(const unsigned char *name
) {
22 unsigned long h
= 5381;
25 for (c
= *name
; c
!= '\0'; c
= *++name
) {
29 return h
& 0xFFFFFFFF;
32 #ifndef HAVE_ELF_POSIX_MEMALIGN
34 struct memalign_info
{
39 int elf_malloc(void **memptr
, size_t alignment
, size_t size
) {
40 char *start_addr
= NULL
;
41 struct memalign_info
*info
;
43 if ((alignment
& (alignment
- 1)) != 0)
45 if (alignment
% sizeof(void*) != 0)
46 alignment
= sizeof(void*);
48 start_addr
= malloc(size
+ (alignment
> sizeof(struct memalign_info
) ?
49 alignment
: sizeof(struct memalign_info
)));
51 if (start_addr
== NULL
)
55 info
= (struct memalign_info
*)(start_addr
-
56 ((unsigned long)start_addr
% alignment
) +
57 alignment
- sizeof(struct memalign_info
));
59 info
->start_addr
= start_addr
;
66 void elf_free(char *memptr
) {
67 struct memalign_info
*info
= (struct memalign_info
*)(memptr
-
68 sizeof(struct memalign_info
));
70 free(info
->start_addr
);
75 int elf_malloc(void **memptr
, size_t alignment
, size_t size
) {
76 if ((alignment
& (alignment
- 1)) != 0)
79 if (alignment
% sizeof(void*) != 0)
80 alignment
= sizeof(void*);
82 return posix_memalign(memptr
, alignment
, size
);
85 void elf_free(void *memptr
) {
89 #endif //HAVE_ELF_POSIX_MEMALIGN