Coder Social home page Coder Social logo

Comments (6)

rui314 avatar rui314 commented on August 17, 2024

Could you share more details about your problem? What are the relocations you are trying to handle?

from mold.

ywgrit avatar ywgrit commented on August 17, 2024

Could you share more details about your problem? What are the relocations you are trying to handle?

Sure.
I'd like to replace the original call to InputSection::apply_reloc_[no]alloc with InputSection::apply_relax. Where apply_relax is a new member function added to the InputSection class that handles relaxation including pcalau12i/addi -> pcaddi.
The copy_chunks (where the relaxation occurs) is followed by apply_relocate(new routine), which invokes OutputSection::apply_relocate to relocate all InputSections.

In the current hypothesis, the calling relationship is as follows

copy_chunks->chunk.copy_buf->OutputSection::write_to->InputSection::write_to->InputSection::apply_relax

apply_relocate->OutputSection::apply_relocate->InputSection::apply_reloc_[no[alloc 

All of these changes are made so that all InputSections have been relocated before relaxation.

from mold.

rui314 avatar rui314 commented on August 17, 2024

Have you read https://github.com/rui314/mold/blob/main/elf/arch-riscv.cc? I believe LoongArch's relaxation is modeled after the RISC-V psABI's, so maybe you can do the same as RISC-V?

from mold.

ywgrit avatar ywgrit commented on August 17, 2024

Have you read https://github.com/rui314/mold/blob/main/elf/arch-riscv.cc? I believe LoongArch's relaxation is modeled after the RISC-V psABI's, so maybe you can do the same as RISC-V?

Thanks.
I've searched for this file before based on "arg.relax", but there is only one case processed in riscv and that case doesn't delete the instruction bytes, so that case doesn't cause the symval to change. But for the case of relaxation that deletes instructions(i.e., pcalau12i/addi -> pcaddi in loongarch), it may cause some of the symbol values to be changed. If relocation is done where the symbols are used before these relaxations are applied, then after the relaxation is applied, the value of the symbols are changed and the relocation is invalidated. That's why maybe we need to do the relaxation before the relocation.

from mold.

rui314 avatar rui314 commented on August 17, 2024

We do support the RISC-V relaxations that remove bytes. Please take a look at riscv_resize_sections in that file.

from mold.

ywgrit avatar ywgrit commented on August 17, 2024

We do support the RISC-V relaxations that remove bytes. Please take a look at riscv_resize_sections in that file.

Sorry for my omission. Thank you, Rui.

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.