This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/RFA] elf64-alpha: Don't put DT_PLTGOT dynamic if no PLT


The following was found/fixed in NetBSD's 2.11.2-based binutils
by Charles Hannum.  The problem is still present in binutils CVS.

The problem occurs when a shared object contains no external references,
and thus has no PLT.  elf64_alpha_size_dynamic_sections() inserts a
DT_PLTGOT entry anyway, which confuses the dynamic linker, resulting in
a crash.  Here is a test case:

 --- a.c ---
fred () { }
 ---

 --- b.c ---
#include <stdio.h>
#include <dlfcn.h>

extern int      fred();

main()
{
        void           *handle;
        void           *symbol;

        handle = dlopen("./a.so", RTLD_NOW);
        if (handle == NULL) {
                printf("dlopen failed");
                exit(1);
        }
        dlclose(handle);
        exit(0);
}
 ---

% /usr/local/gnu/bin/gcc -shared -o a.so a.c
% /usr/local/gnu/bin/gcc -o b b.c
% ./b
pid 1969 (b): unaligned access: va=0x16001447c pc=0x1600144dc ra=0x160026a68 sp=0x1fffff368 op=ldq
Memory fault (core dumped) 
%

(FWIW, the test case was essentially extracted from autoconf tests performed
by perl and zsh.)

The following patch fixes the problem by only adding DT_PLTGOT if there
is a PLT.

OK for mainline?

OK for 2.13 branch?

OK for 2.12 branch?

	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only insert
	DT_PLTGOT into the dynamic section if there is a PLT.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

Attachment: alpha-patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]