[Bug gold/18845] New: Using emit-relocs and icf ends in assert fail.
https://sourceware.org/bugzilla/show_bug.cgi?id=18845 Bug ID: 18845 Summary: Using emit-relocs and icf ends in assert fail. Product: binutils Version: 2.25 Status: NEW Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: johan.karlsson at enea dot com CC: ian at airs dot com Target Milestone: --- Created attachment 8529 --> https://sourceware.org/bugzilla/attachment.cgi?id=8529&action=edit The patch that is described in the comment. test.c: main(){ return 0; } CFLAGS="-fuse-ld=gold -Wl,--emit-relocs -Wl,--icf=safe" make test cc -fuse-ld=gold -Wl,--emit-relocs -Wl,--icf=safetest.c -o test /usr/bin/ld.gold: internal error in do_layout, at ../../gold/object.cc:1723 collect2: error: ld returned 1 exit status make: *** [test] Error 1 I'm attaching a patch that fixes this problem. It changes so that the relocation sections are not added until the second pass in do_layout(). I also changed the assert to what I believe is the intended behavior, it is more in line with the handling of the eh_frame 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 gold/18845] Using emit-relocs and icf ends in assert fail.
https://sourceware.org/bugzilla/show_bug.cgi?id=18845 Johan Karlsson changed: What|Removed |Added CC||johan.karlsson at enea dot com -- 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 gold/18846] New: gold PowerPC --emit-relocs differ from ld
https://sourceware.org/bugzilla/show_bug.cgi?id=18846 Bug ID: 18846 Summary: gold PowerPC --emit-relocs differ from ld Product: binutils Version: 2.25 Status: NEW Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: johan.karlsson at enea dot com CC: ian at airs dot com Target Milestone: --- Created attachment 8530 --> https://sourceware.org/bugzilla/attachment.cgi?id=8530&action=edit gold_ppc_rela_addend.patch When using --emit-relocs on PowerPC, gold recalculates the addend in the relocation entry to include the symbol value. When using ld the symbol value is not added to the addend. Example: readelf -r test.elf Offset InfoTypeSym.Value Sym. Name + Addend gold 010004e2 0304 R_PPC_ADDR16_LO 010200c0 .bss + 1020140 ld 010004e2 0304 R_PPC_ADDR16_LO 010200c0 .bss + 80 I attached a patch that solves this. I don't know if it's a copy past error or if the changed behavior is intended. -- 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 gold/18846] gold PowerPC --emit-relocs differ from ld
https://sourceware.org/bugzilla/show_bug.cgi?id=18846 Johan Karlsson changed: What|Removed |Added CC||johan.karlsson at enea dot com -- 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 gold/18847] New: Gold: Address of section moves backward when aligned.
https://sourceware.org/bugzilla/show_bug.cgi?id=18847 Bug ID: 18847 Summary: Gold: Address of section moves backward when aligned. Product: binutils Version: 2.25 Status: NEW Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: johan.karlsson at enea dot com CC: ian at airs dot com Target Milestone: --- Created attachment 8532 --> https://sourceware.org/bugzilla/attachment.cgi?id=8532&action=edit section_pointer_increase.patch When using a linker script that added alignment for the output section I got the following error: ld.gold: error: address of section '.bss' moves backward from 0x10200b0 to 0x101ecc0 Simplified the linker script looked like this: .data ALIGN(0x1) : { *(.data) *(.data.*) *(.gnu.linkonce.d.*) SORT(CONSTRUCTORS) } > mem :ph_ram .bss : { *(.bss) *(.bss.*) *(COMMON) *(.gnu.linkonce.b.*) } > mem :ph_ram I'm attaching a patch that fixes the problem. The way I saw it was that when the alignment was added a specific address was assigned to that section and there by the output section pointer was not increased with its size. -- 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 gold/18845] Using emit-relocs and icf ends in assert fail.
https://sourceware.org/bugzilla/show_bug.cgi?id=18845 --- Comment #2 from Johan Karlsson --- Right now there is a check for the -r/--gc-section/--icf combination in queue_initial_tasks(), however I think I saw a PR about it generating lots of error afterwards. Can't find it though. I don't think the patch I attached would end in an assert failing when using -r in combination with --gc-section or --icf. I'm using it to relocate a program when loading it on an embedded system. Why not an relocatable ELF is used would be due to legacy, however it works quite well to do it this way. The only drawback would be that most of the relocation entries are unnecessary. -- 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 gold/18847] Gold: Address of section moves backward when aligned.
https://sourceware.org/bugzilla/show_bug.cgi?id=18847 --- Comment #2 from Johan Karlsson --- Created attachment 8534 --> https://sourceware.org/bugzilla/attachment.cgi?id=8534&action=edit Linker script I was able to reproduce it easily with my toolchain, but when I tried the toolchain on my local distro (Binutils 2.24) I got an additional error about segments overlap(ld.gold: error: load segment overlap [0x100 -> 0x148] and [0x10b -> 0x101] ) Reproduce like this using the attached linker script. test.c: main(){ return 0; } gcc -c -o test.o test.c ld.gold -T script.lcf test.o ld.gold: error: address of section '.bss' moves backward from 0x101 to 0x10b If I remove ALIGN from .data no error is seen. Using the attached patch I get no error when using section alignment or not. The patch might not be enough since I did not look into the root cause for the this->address_ being set. -- 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 gold/14746] ld: internal error in address, at gold/output.h:72 while building Linux kvm tool
https://sourceware.org/bugzilla/show_bug.cgi?id=14746 Johan Karlsson changed: What|Removed |Added CC||johan.karlsson at enea dot com --- Comment #7 from Johan Karlsson --- Created attachment 8537 --> https://sourceware.org/bugzilla/attachment.cgi?id=8537&action=edit Linker script repo I think I'm able to reproduce this issue. What I had to do to reproduce it was to add a symbol in my linker script that pointed to the address of .eh_frame. It's the same assert but I'm not sure that it's the same problem. Repo: test.c main(){ return 0; } g++ -c -o test.o test.c test.o need to contain an eh_frame. ld.gold -T script.lcf test.o ld.gold: internal error in address, at ../../gold/output.h:73 -- 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 gold/18935] New: Gold assert fail when moving dot in NOLOAD section.
https://sourceware.org/bugzilla/show_bug.cgi?id=18935 Bug ID: 18935 Summary: Gold assert fail when moving dot in NOLOAD section. Product: binutils Version: 2.25 Status: NEW Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: johan.karlsson at enea dot com CC: ian at airs dot com Target Milestone: --- ld.gold: internal error in set_address, at gold/output.h:197 The version I run is Binutils 2.25 with bug fixes for PR18846, PR18847, and PR18746. I believe it would be reproducible on master. Also, this might be a regression from PR18847. Repo: test.c: int main() { return 0; } script.lcf: PHDRS { ph_load PT_LOAD ; } SECTIONS { .text : { *(.text) } :ph_load = 0 .data ALIGN(0x2000) : { *(.data) } :ph_load .bss : { *(.bss) } :ph_load .init_stack (NOLOAD) : { . = . + 0x200; } :ph_load } gcc -c -o test.o test.c ld.gold -T script.lcf test.o ld.gold: internal error in set_address, at gold/output.h:197 -- 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 gold/18935] Gold assert fail when moving dot in NOLOAD section.
https://sourceware.org/bugzilla/show_bug.cgi?id=18935 --- Comment #1 from Johan Karlsson --- This is not a regression from PR18847. Seems a bit unclear what the expected behavior is. .init_stack (NOLOAD) : { . = . + 0x200; } :ph_load With this ld.bfd creates a NOBITS SHF_ALLOC section(just like .bss). When a new non-SHF_ALLOC output section is created the address is set to 0. Layout::make_output_section_for_script(), which is the function that creates the init_stack section, only tries to create sections with SHT_PROGBITS section. This is why the assert fails when Output_section_definition::set_section_addresses() tries to assign an address to the 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 gold/18935] Gold assert fail when moving dot in NOLOAD section.
https://sourceware.org/bugzilla/show_bug.cgi?id=18935 --- Comment #3 from Johan Karlsson --- (In reply to Cary Coutant from comment #2) > > Seems a bit unclear what the expected behavior is. > > > > .init_stack (NOLOAD) : > > { > >. = . + 0x200; > > } :ph_load > > With this ld.bfd creates a NOBITS SHF_ALLOC section(just like .bss). > > > > When a new non-SHF_ALLOC output section is created the address is set to 0. > > Layout::make_output_section_for_script(), which is the function that creates > > the init_stack section, only tries to create sections with SHT_PROGBITS > > section. This is why the assert fails when > > Output_section_definition::set_section_addresses() tries to assign an > > address > > to the section. > > This script looks like it's trying to create an unloadable section, > then allocate it to a loadable segment. If all the script is trying to > do is create a loadable NOBITS section, the NOLOAD attribute shouldn't > be necessary (or allowed). The fact that it contains nothing but > uninitialized space should be sufficient. I don't think gold does the > right thing in that case, but that ought to be the bug, not that > NOLOAD should make it work. > > What does Gnu ld do if you omit NOLOAD? Do you have any history that > explains why NOLOAD was added to the script? > > -cary When removing NOLOAD Gnu ld still makes it a NOBITS section, guess it recognizes that it is empty and does that. Because if I just add an int to that section it will create it as PROGBITS. And if I then add the NOLOAD again it is back to NOBITS. The linker scripts are for embedded systems that usually load binaries. So if we put things in NOLOAD section the binaries are smaller. This PR is highly tied to the discussion in the mailing list. Seems like NOLOAD is implemented in gold just as described by the linker documentation. However Gnu ld does not do that for ELF, see ld/ldlang.c /* Unfortunately GNU ld has managed to evolve two different meanings to NOLOAD in scripts. ELF gets a .bss style noload, alloc, no contents section. All others get a noload, noalloc section. */ I think the best is to change the behavior of gold to be compatible with Gnu ld. /Johan -- 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 gold/18935] Gold assert fail when moving dot in NOLOAD section.
https://sourceware.org/bugzilla/show_bug.cgi?id=18935 --- Comment #5 from Johan Karlsson --- (In reply to Cary Coutant from comment #4) > > This script looks like it's trying to create an unloadable section, > > then allocate it to a loadable segment. If all the script is trying to > > do is create a loadable NOBITS section, the NOLOAD attribute shouldn't > > be necessary (or allowed). The fact that it contains nothing but > > uninitialized space should be sufficient. I don't think gold does the > > right thing in that case, but that ought to be the bug, not that > > NOLOAD should make it work. > > That GOLD makes BSS sections take up space in the output file is PR 16711. Ok, I have a patch that fixes noload sections so that they work as gnu ld does. With that change I also fix this PR. I also fixed PR 16711, I will try and seperate them and post the bss fix in PR 16711. -- 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