This is the mail archive of the binutils@sourceware.org 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]

Re: Issue while using -rdynamic with binutils 2.22-8


On 30/01/14 10:43 AM, H.J. Lu wrote:
On Thu, Jan 30, 2014 at 7:09 AM, Makarand Pradhan
<makarandpradhan@ruggedcom.com>  wrote:
On 29/01/14 06:26 PM, H.J. Lu wrote:
On Wed, Jan 29, 2014 at 2:12 PM, H.J. Lu<hjl.tools@gmail.com>   wrote:
On Wed, Jan 29, 2014 at 1:31 PM, Makarand Pradhan
<makarandpradhan@ruggedcom.com>   wrote:
Hi All,

We are in the process of migrating from binutils 2.20.1-16 to 2.22-8.

I notice an issue while using linker option -rdynamic. Details below:

I'm using the sample code given at the end of this email for the test.
The
code links fine in 2.20.1-16, but fails in 2.22-8.

e.g.:
In 2.20.1-16:
# g++ -ffunction-sections -fdata-sections -rdynamic -Wl,--gc-sections
t.cpp
#

In 2.22-8:
# g++ -ffunction-sections -fdata-sections -rdynamic -Wl,--gc-sections
t.cpp
/tmp/ccU6re3d.o: In function `c1_type::c1_func1()':
t.cpp:(.text._ZN7c1_type8c1_func1Ev+0x12): undefined reference to
`c1_type::int_1'
t.cpp:(.text._ZN7c1_type8c1_func1Ev+0x1e): undefined reference to
`c1_type::int_1'
collect2: ld returned 1 exit status

Problem:
The unused code is supposed to be stripped of by -Wl,--gc-sections. When
used alone it works as expected. All the same when paied with ïrdynamic
the
build fails in the newer version.

Would appreciate any opinions if this is a bug or if I'm missing
anything.

Warm Rgds,
Makarand.

System configuration:
# uname -a
Linux makarandpradhan-ppc 3.2.0-0.bpo.4-powerpc64 #1 SMP Debian
3.2.41-2+deb7u2~bpo60+1 ppc GNU/Linux # cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/";
SUPPORT_URL="http://www.debian.org/support/";
BUG_REPORT_URL="http://bugs.debian.org/";


File: t.cpp
#include<stdio.h>

class c1_type
{
public:
static int int_1;

void c1_func1(void);
};

void c1_type::c1_func1()
{
int_1 = 25;
}

int main()
{
return 0;
}

This regression is caused by

https://sourceware.org/ml/binutils/2011-11/msg00056.html

I think your code is invalid.  You need either to provide definition
for

static int int_1;

or drop -rdynamic.

Hi H.J. Lu,

Appreciate your replies.

The definition is intentionally dropped so that it is stripped by
-Wl,--gc-sections. Only when used in conjunction with -rdynamic it causes a
problem.

I could successfully use both -Wl,--gc-sections and -rdynamic in 2.20.1-16
but it fails in 2.22-8.

That's why I was wondering if any commit has caused this change. And if this
is intentional or a bug.


-rdynamic tells linker to make ALL global symbols available for
dynamic linking, including those unused.  You have

void c1_type::c1_func1()
{
int_1 = 25;
}

Linker will export it even if --gc-sections is used.  When -rdynamic
is used, --gc-sections will only discard unused LOCAL symbols.
This is the bug fixed in binutils 2.21.

Thanks.

--
Makarand Pradhan
Software Engineer Ruggedcom
Siemens Canada Limited
Industry Sector
300 Applewood Crescent,
Vaughan, ON, L4K 5C7
Tel: 905 482 4572
e-mail:  makarand.pradhan@siemens.com
www.ruggedcom.com


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