Coder Social home page Coder Social logo

Comments (7)

rui314 avatar rui314 commented on July 19, 2024 1

Thank you for your report! At least one of your crt files is broken. See the following readelf output.

$ readelf -a lib/crti.o
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          280 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         7
  Section header string table index: 1

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB          0000000000000000 0000c8 000049 00      0   0  1
  [ 2] .text             PROGBITS        0000000000000000 000040 000000 00  AX  0   0  4
  [ 3] .note.GNU-stack   PROGBITS        0000000000000000 000040 000000 00      0   0  1
  [ 4] .init             PROGBITS        0000000000000000 000040 000008 00  AX  0   0  1
  [ 5] .fini             PROGBITS        0000000000000000 000048 000008 00  AX  0   0  1
  [ 6] .symtab           SYMTAB          0000000000000000 000050 000078 18      1   3  8
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), p (processor specific)

There are no section groups in this file.

There are no program headers in this file.

There is no dynamic section in this file.

There are no relocations in this file.

The decoding of unwind sections for machine type AArch64 is not currently supported.

Symbol table '.symtab' contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    4 $x.0
     2: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    5 $x.1
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT    4 _init
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT    5 _fini

No version information found in this file.

.init and .fini are marked as executable sections, but their alignment requirements are set to just 1. Since all instructions need to be aligned to 4 byte boundaries on ARM64, the processor report it as an illegal instruction. mold just does what that is told to do, so it's not a mold's bug. Maybe with other linkers .inti and .fini happen to be aligned to 4 byte boundaries, but depending on that coincidence is wrong.

Please report it to your distro vendor so that they can fix their shipped binary files.

For tracking purposes, please share the bug report link as a reply to this issue. Thanks!

from mold.

mojyack avatar mojyack commented on July 19, 2024

Thanks for taking the time.
This bug seems to be a musl issue.
I was able to fix this by applying this patch to musl:

diff --git a/crt/aarch64/crti.s b/crt/aarch64/crti.s
index 775df0ac..3776fa64 100644
--- a/crt/aarch64/crti.s
+++ b/crt/aarch64/crti.s
@@ -1,6 +1,7 @@
 .section .init
 .global _init
 .type _init,%function
+.align 2
 _init:
 	stp x29,x30,[sp,-16]!
 	mov x29,sp
@@ -8,6 +9,7 @@ _init:
 .section .fini
 .global _fini
 .type _fini,%function
+.align 2
 _fini:
 	stp x29,x30,[sp,-16]!
 	mov x29,sp

from mold.

mojyack avatar mojyack commented on July 19, 2024

I would like to send this patch to the musl team, but I am not familiar with the mailing list.
So I am thinking of sending it to the Gentoo repository.
Any ideas?

from mold.

rui314 avatar rui314 commented on July 19, 2024

If you report the issue to Gentoo, I'm sure they'll forward it to upstream if it's an upstream bug.

from mold.

mojyack avatar mojyack commented on July 19, 2024

I see, I'll do that.

from mold.

mojyack avatar mojyack commented on July 19, 2024

https://bugs.gentoo.org/931782
bug report posted

from mold.

rui314 avatar rui314 commented on July 19, 2024

I'll close this issue as it's not mold's bug.

from mold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.