[Bug ld/19803] gc-sections breaks PE DLL variable export

2016-03-25 Thread martin.koegler at chello dot at
https://sourceware.org/bugzilla/show_bug.cgi?id=19803

--- Comment #20 from martin.koegler at chello dot at ---
(In reply to Nick Clifton from comment #19)
> > In my option, this change is not necessary, as it just would hides broken 
> > symbols in the export library.
> 
> Actually I think that it is needed in order to prevent garbage collected
> symbols from leaking into the export table.

Such symbols would still be exported in the DLL export table and ld can
directly against the DLL binary [and therefore such symbols].

The goal of our last patches was to avoid that any exported symbol gets garbage
collected - so a bug free ld shouldn't hit any such symbols.

The only benefit could be, that we generate a link error, if we hit a ld gc-bug
and link against the import library.

As any such symbol is a bug, we could change it to a "you found a gc-section
bug - please report it" error.

> > There is second case missing (symbol matching implemented by 
> > pe_fixup_stdcalls).
> 
> OK - this revised patch contains an attempt to fix this function as well. 
> Please could you give it a try and let me know the results.

It works for my simplified test cases. I found another issue with the entry
symbol - lang_end interprets an undefined symbols in other ways too:
  /* We couldn't find the entry symbol.  Try parsing it as a
 number.  */
 /* Can't find the entry symbol, and it's not a number.  Use
 the first address in the text section.  */

Try my sample of Comment #15 - the text section is still removed, although ld
uses the first address of the text section.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/17334] building gcc-4.5.4 hits BFD (GNU Binutils) 2.25 assertion fail elf32-bfin.c:4457

2016-03-25 Thread wbx at openadk dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=17334

--- Comment #10 from wbx at openadk dot org ---
Hi,

yes, this change works for me. Tested with binutils 2.26 and git.

best regards
 Waldemar

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


Fwd: gold --incremental not producing DWARF such that nm can handle it, internal error

2016-03-25 Thread Britton Kerin
I'm forwarding this because it sounds useful.  I'd love to see nm and
addr2line work correctly with things produce using the gold linker.

On Thu, Mar 24, 2016 at 11:54 AM, Cary Coutant  wrote:
>> * --incremental gold produces binaries st nm --line-numbers complains like 
>> this:
>>
>>  $ nm --line-numbers instrument_test >/dev/null
>>  nm: Dwarf Error: Bad abbrev number: 0.
>>  nm: Dwarf Error: found dwarf version '0', this reader only
>> handles version 2, 3 and 4 information.
>>  nm: Dwarf Error: found dwarf version '0', this reader only
>> handles version 2, 3 and 4 information.
>>
>>   nm still coughs up the requested information but these are pretty
>> disturbing warnings.
>
> Gold adds padding to most sections during the first (full) incremental
> link. For .debug_info sections, it makes the padding look like an
> empty compilation unit, but other sections just get padded with
> zeroes. I believe nm here is trying to read the .debug_line section,
> assuming that it consists of one compilation unit after another. The
> padding is at the end, so it's already found what it needs to by the
> time it prints those messages. To work with incremental linking, nm
> (and addr2line) will probably have to start with the .debug_info
> section, which has pointers to each compilation unit's line number
> table.

Britton

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


Vagueness and inconsistency in -shared -fPIC -fpic -pie option descriptions

2016-03-25 Thread Britton Kerin
On Thu, Mar 24, 2016 at 11:21 AM, Jeffrey Walton  wrote:
> On Wed, Mar 23, 2016 at 6:12 PM, Britton Kerin  
> wrote:
>> I can't tell from the manual if -fPIC is safe for executable programs,
>> or only for libraries.
>>
>> I want to use -fPIC or -fPIE so dladdr() will work right.  I would
>> rather use -fPIC if possible, because it seems simpler to use one such
>> option for everything if possible.
>
> You can build all your object files with -fPIC.
>
> When you build you shared library you can use the object files and:
>
> g++ -shared myobj1.o myobj2.o ... -o mylib.so
>
> When you build your program you use the same object files and:
>
> g++ -pie myobj1.o myobj2.o ... -o myprog.exe

It seems like this approach is not allowed according to the docs.
But perhaps the gcc/ld docs themselves need to be fixed.  Currently in
gcc 5.3.0 docs section 3.13 Options for Linking:

 -pie  Produce a position independent executable on targets
that support it. For predictable results, you must also specify the
same set of options used for compilation (-fpie, -fPIE, or model
suboptions) when you specify this linker option.
 ...
 -sharedProduce a shared object which can then be linked with
other objects to form an executable. Not all systems support this
option. For predictable results, you must also specify the same set of
options used for compilation (-fpic, -fPIC, or model suboptions) when
you specify this linker option.

which seems to preclude the arrangement you describe above: the docs
seem to be saying that -fPIC is also required at link time.  Doing
that seems to work, but gcc docs section  3.18 Options for Code
Generation Conventions says:

 -fpic Generate position-independent code (PIC) suitable for
use in a shared library, if supported for the target machine. Such
code accesses all constant addresses through a global offset table
(GOT). The dynamic loader resolves the GOT entries when the program
starts (the dynamic loader is not part of GCC; it is part of the
operating system). If the GOT size for the linked executable exceeds a
machine-specific maximum size, you get an error message from the
linker indicating that -fpic does not work; in that case, recompile
with -fPIC instead  (These maximums are 8k on the SPARC and 32k on the
m68k and RS/6000. The x86 has no such limit.)

 Position-independent code requires special support, and therefore
works only on certain machines. For the x86, GCC supports PIC for
System V but not for the Sun 386i. Code generated for the IBM RS/6000
is always position-independent.

 When this flag is set, the macros __pic__ and __PIC__ are defined to 1.

 -fPIC If supported for the target machine, emit
position-independent code, suitable for dynamic linking and avoiding
any limit on the size of the global offset table. This option makes a
difference on the m68k, PowerPC and SPARC.

 Position-independent code requires special support, and therefore
works only on certain machines.

 When this flag is set, the macros __pic__ and __PIC__ are defined to 2.

The description of -fpic together with the existence of -fpie makes it
seem doubtful that -fpic generated code is suitable for executables,
so it's description should probably be changed somehow if it's ok to
just use -fPIC everywhere.

In GNU ld docs for binutils 2.2.6 section 2.1 Command Line Options:

 -pie
 --pic-executable Create a position independent executable.
This is currently only supported on ELF platforms. Position
independent executables are similar to shared libraries in that they
are relocated by the dynamic linker to the virtual address the OS
chooses for them (which can vary between invocations). Like normal
dynamically linked executables they can be executed and symbols
defined in the executable cannot be overridden by shared libraries.

No mention of the requirement to agree with compile-time options here.
Assuming the requirement for agreement applies here, it should be
mentioned as it is in the gcc docs.  Perhaps the linker -pie option
isn't the same as the gcc -pie link time option, but if so that's
pretty weird and deserving of some explanation.

Unless I'm missing something I'll file gcc and binutils doc bugs for
these issues.


Britton

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils