[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#864551: gcc-6: linker symbol incorrectly decoded in C code



Package: gcc-6
Version: 6.3.0-18
Severity: normal
Tags: upstream

Dear Maintainer,

When using the linker symbols, the values of the adresses of the symbols
are incorrectly decoded.

The problem occurs with the linker scripts but also with the following
small code and minimalist compiler options:

The test code:

#include <stdio.h>

extern unsigned char liloo;
extern unsigned char lilootab[];

static void * spa = & liloo;
static void * sta = lilootab;

int main() {
    void * pa = & liloo;
    void * ta = lilootab;
    printf("%p %p %p %p\n", spa, sta, pa, ta);
    return 0;
}

The compilation with gcc-6:
gcc-6 -g -c testld.c
gcc-6 -fuse-ld=bfd -Wl,--defsym=liloo=0x1000000 -Wl,--defsym=lilootab=0x2000000 testld.o -o testld-6

The incorrect execution:
./testld-6
0x55bf6cc0c000 0x55bf6dc0c000 0x55bf6cc0c000 0x55bf6dc0c000

The symbol table is still correct according to objdump:

$ objdump -t testld-6 | grep liloo
0000000002000000 g       *ABS*	0000000000000000              lilootab
0000000001000000 g       *ABS*	0000000000000000              liloo


The compilation with gcc-5
gcc-5 -g -c testld.c
gcc-5 -fuse-ld=bfd -Wl,--defsym=liloo=0x1000000 -Wl,--defsym=lilootab=0x2000000 testld.o -o testld-5

The correct execution:
./testld-5
0x1000000 0x2000000 0x1000000 0x2000000

Using linker:
no change using gold instead of bfd

Using other compilers:

The bug occurs with gcc-6 (6.3.0-18) and gcc-7 (7.1.0-6) in experimental

Correct execution occurs with with gold and bfd:
gcc-4.8,4.9,5.0 and clang 3.6,3.7,3.8,3.9,4.0,5.0



-- System Information:
Debian Release: 9.0
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.11.0-trunk-amd64 (SMP w/8 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), LANGUAGE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-6 depends on:
ii  binutils      2.28-5
ii  cpp-6         6.3.0-18
ii  gcc-6-base    6.3.0-18
ii  libc6         2.24-11
ii  libcc1-0      7.1.0-6
ii  libgcc-6-dev  6.3.0-18
ii  libgcc1       1:7.1.0-6
ii  libgmp10      2:6.1.2+dfsg-1
ii  libisl15      0.18-1
ii  libmpc3       1.0.3-1+b2
ii  libmpfr4      3.1.5-1
ii  libstdc++6    6.3.0-18
ii  zlib1g        1:1.2.8.dfsg-5

Versions of packages gcc-6 recommends:
ii  libc6-dev  2.24-11

Versions of packages gcc-6 suggests:
ii  gcc-6-doc         6.3.0-1
pn  gcc-6-locales     <none>
pn  gcc-6-multilib    <none>
pn  libasan3-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx2-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information


Reply to: