This is the mail archive of the 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();

        void           *handle;
        void           *symbol;

        handle = dlopen("./", RTLD_NOW);
        if (handle == NULL) {
                printf("dlopen failed");

% /usr/local/gnu/bin/gcc -shared -o 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 <>

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]