Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISCV] Add zero-page relaxation #687

Merged
merged 4 commits into from
Sep 5, 2022
Merged

[RISCV] Add zero-page relaxation #687

merged 4 commits into from
Sep 5, 2022

Conversation

ksco
Copy link
Contributor

@ksco ksco commented Sep 2, 2022

Currently, this patch fails at tests with -static option and needs more work to do before merging.

Also, seems TLS relaxation(#461) is already supported. We only have global-pointer relaxation(#460) left to do for RISC-V.

@ksco ksco marked this pull request as draft September 2, 2022 17:39
@rui314
Copy link
Owner

rui314 commented Sep 3, 2022

Generally looking good, but unlike R_RISCV_CALL_PLT, data may be referenced by HI20+LUI, so we need to handle section fragments when computing target addresses, no?

@ksco
Copy link
Contributor Author

ksco commented Sep 3, 2022

Thanks, the newly pushed code handles section fragments.

elf/arch-riscv.cc Outdated Show resolved Hide resolved
@ksco
Copy link
Contributor Author

ksco commented Sep 3, 2022

Also, the LUI -> C.LUI relaxation seems too restrictive and I don't know under what circumstances it would be triggered. For example, how do we write tests for this relaxation?

elf/arch-riscv.cc Outdated Show resolved Hide resolved
@rui314
Copy link
Owner

rui314 commented Sep 4, 2022

Also, the LUI -> C.LUI relaxation seems too restrictive and I don't know under what circumstances it would be triggered. For example, how do we write tests for this relaxation?

I believe you can place a function in its own section using __attribute__((section(".low"))) and place it at the very beginning of the virtual address space with -Wl,--section-start=.low=0x16.

I don't think LUI → C.LUI is useful on Unix, but it might be in embedded programming.

@ksco
Copy link
Contributor Author

ksco commented Sep 4, 2022

I believe you can place a function in its own section using __attribute__((section(".low")))...

Thanks, I added a c.lui test, but it segfaulted under riscv64, but I believe it's unrelated to this patch.

@rui314
Copy link
Owner

rui314 commented Sep 4, 2022

Maybe the first few pages are kept unmapped to catch null pointer accesses?

There might be no way to test this on Unix. If you wrote a bootloader-ish program, you could test it, but I doubt if it's necessary. I wouldn't implement LUI → C.LUI relaxation in the first place as it doesn't seem useful.

@ksco
Copy link
Contributor Author

ksco commented Sep 4, 2022

I created a separate bug #688.

@ksco
Copy link
Contributor Author

ksco commented Sep 4, 2022

I wouldn't implement LUI → C.LUI relaxation in the first place as it doesn't seem useful.

Agreed, I realized this after implementing, maybe I just remove this relaxation then.

@ksco ksco changed the title [RISCV] Add compressed LUI relaxation & zero-page relaxation [RISCV] Add zero-page relaxation Sep 4, 2022
@ksco ksco marked this pull request as ready for review September 4, 2022 08:08
@ksco
Copy link
Contributor Author

ksco commented Sep 4, 2022

@rui314 Thanks for the help, I think now it's ready for review.

@rui314 rui314 merged commit ddbf501 into rui314:main Sep 5, 2022
@ksco ksco deleted the relax branch September 7, 2022 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants