https://sourceware.org/bugzilla/show_bug.cgi?id=27200
Nelson Chu <nelson.chu1990 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nelson.chu1990 at gmail dot com --- Comment #11 from Nelson Chu <nelson.chu1990 at gmail dot com> --- Hi Guys, Jim had resolved the similar problem before, here is the details, https://sourceware.org/bugzilla/show_bug.cgi?id=24389 However, after the fixed, I think there is only one case that will cause the "-b binary" cannot work expected - Link the binary file without any ABI setting as the first linked object. The _bfd_riscv_elf_merge_private_bfd_data copy the flags from input BFD to output BFD if elf_flags_init (obfd) is FALSE. Therefore, we may copy the 0x0 flag from the binary file, if it is linked first. I suppose the Makefile in the Description should work, since the first linked object is kernel.o rather than the binary font.o. However, the following untested patch might work, diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index b2ec6a2..578b29a 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -3804,13 +3804,6 @@ _bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) new_flags = elf_elfheader (ibfd)->e_flags; old_flags = elf_elfheader (obfd)->e_flags; - if (! elf_flags_init (obfd)) - { - elf_flags_init (obfd) = TRUE; - elf_elfheader (obfd)->e_flags = new_flags; - return TRUE; - } - /* Check to see if the input BFD actually contains any sections. If not, its flags may not have been initialized either, but it cannot actually cause any incompatibility. Do not short-circuit dynamic objects; their @@ -3836,7 +3829,18 @@ _bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) } if (null_input_bfd || only_data_sections) - return TRUE; + { + if (! elf_flags_init (obfd)) + elf_elfheader (obfd)->e_flags = new_flags; + return TRUE; + } + } + + if (! elf_flags_init (obfd)) + { + elf_flags_init (obfd) = TRUE; + elf_elfheader (obfd)->e_flags = new_flags; + return TRUE; } At the beginning, I move "if (! elf_flags_init (obfd))" behind the input BFD checking, to avoid copying the flags from the binary file with 0x0 flags. But the change causes the ld testcase "Link with zlib-gabi compressed debug output 1" fails for rv64gc-linux toolchain... Therefore, I still copy the 0x0 flags to the output BFD, if it is linked as the first files. But without turning the elf_flags_init (obfd) to TRUE. This looks like a hack, but I don't know why currently... Thanks Nelson -- You are receiving this mail because: You are on the CC list for the bug.