Page MenuHomeFreeBSD

fbsd-phab_maskray.me (Fangrui Song)
User

Projects

User does not belong to any projects.

User Details

User Since
Jul 27 2018, 2:48 AM (330 w, 3 d)

Recent Activity

Dec 9 2023

fbsd-phab_maskray.me added a comment to D31261: Add arm64 pointer authentication support.

This patch has landed (https://github.com/freebsd/freebsd-src/commit/85b7c566f1538f9a2e85f76bf5b41380701987a7) but this revision is not marked as closed.

Dec 9 2023, 8:15 PM

Oct 29 2023

fbsd-phab_maskray.me accepted D42388: add asan_static to build.
Oct 29 2023, 6:33 PM
fbsd-phab_maskray.me added a comment to D42388: add asan_static to build.

ld: error: cannot open /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/16/lib/freebsd/libclang_rt.asan_static-x86_64.a: No such file or directory

Oct 29 2023, 6:32 PM

Apr 12 2023

fbsd-phab_maskray.me added a comment to D39517: rtld: fix SysV hash function overflow.

elf_hash((const unsigned char *)"ZZZZZW9p")) == 100000000. This is an all-ascii-alphanumeric identifier.
For extra fun, you may try ld -shared --hash-style=sysv and ensure 100000000 % nbucket != 0 (lld sets nbucket to the number of dynamic symbols) and see whether the dynamic symbol cannot be bound without this patch:)

Apr 12 2023, 4:47 PM
fbsd-phab_maskray.me added a comment to D39517: rtld: fix SysV hash function overflow.
Apr 12 2023, 4:42 PM
fbsd-phab_maskray.me accepted D39517: rtld: fix SysV hash function overflow.

LGTM. I made a post last night and did plan to make this FreeBSD change for my exercise, but you beat it to me :)

Apr 12 2023, 4:36 PM

Jul 22 2022

fbsd-phab_maskray.me added a comment to D35870: Add ELFCOMPRESS_ZSTD constant.

Cary has accepted this value on https://groups.google.com/g/generic-abi/c/satyPkuMisk/m/KwTF_U8rBAAJ

Jul 22 2022, 11:09 PM
fbsd-phab_maskray.me accepted D35870: Add ELFCOMPRESS_ZSTD constant.

Thanks! I don't want llvm-project to be blocked by the generic-ABI's keeping postponing, too. I guess if FreeBSD decides to define this, llvm-project can move on, too.

Jul 22 2022, 4:47 AM

Feb 25 2022

fbsd-phab_maskray.me added a comment to D34379: llvm: [ELF] Support some absolute/PC-relative relocation types for REL format .

You may cherry pick https://github.com/llvm/llvm-project/commit/53fc5d9b9a0110f097c6e9f7aa3bff3621eaf268 to avoid the local changes.

Feb 25 2022, 8:51 PM · PowerPC

Feb 9 2022

fbsd-phab_maskray.me added a comment to D34215: crunchgen: remove -Wl,-dc.

Double-checking, Fangrui Song <i@maskray.me> is the correct author info?

Feb 9 2022, 5:58 AM
fbsd-phab_maskray.me updated the diff for D34215: crunchgen: remove -Wl,-dc.

remove -dc from comment

Feb 9 2022, 12:46 AM

Feb 8 2022

fbsd-phab_maskray.me updated the diff for D34215: crunchgen: remove -Wl,-dc.

Fix comment

Feb 8 2022, 10:36 PM
fbsd-phab_maskray.me planned changes to D34215: crunchgen: remove -Wl,-dc.

Needs to fix a comment.

Feb 8 2022, 10:29 PM
fbsd-phab_maskray.me requested review of D34215: crunchgen: remove -Wl,-dc.
Feb 8 2022, 10:26 PM

Nov 1 2021

fbsd-phab_maskray.me added a comment to D32524: rtld: Support DT_RELR relative relocation format.

Folks may be interested in

Nov 1 2021, 8:34 PM

Oct 16 2021

fbsd-phab_maskray.me added a comment to D32524: rtld: Support DT_RELR relative relocation format.

git format-patch -2 --stdout of D32526 + D32524: https://gist.github.com/MaskRay/4df58dc970a377d04ec93a983685f1d4

Oct 16 2021, 9:38 PM
fbsd-phab_maskray.me updated the diff for D32524: rtld: Support DT_RELR relative relocation format.

address style issues

Oct 16 2021, 9:35 PM
fbsd-phab_maskray.me requested review of D32526: sys: Add definitions for RELR relative relocation format.
Oct 16 2021, 9:33 PM
fbsd-phab_maskray.me added a comment to D32524: rtld: Support DT_RELR relative relocation format.

ld.lld's RELR is robust since 2019-04 (https://reviews.llvm.org/D67164) when I fixed an oscillation bug.

Oct 16 2021, 8:55 PM
fbsd-phab_maskray.me added inline comments to D32524: rtld: Support DT_RELR relative relocation format.
Oct 16 2021, 8:49 PM
fbsd-phab_maskray.me updated the diff for D32524: rtld: Support DT_RELR relative relocation format.

address comments

Oct 16 2021, 8:49 PM
fbsd-phab_maskray.me updated the summary of D32524: rtld: Support DT_RELR relative relocation format.
Oct 16 2021, 7:14 PM
fbsd-phab_maskray.me updated the diff for D32524: rtld: Support DT_RELR relative relocation format.

const char* -> const char *

Oct 16 2021, 7:02 PM
fbsd-phab_maskray.me added a comment to D32524: rtld: Support DT_RELR relative relocation format.

RELR is like a modern version of Firefox’s ELF hack https://glandium.org/blog/?p=1177#relocations

Oct 16 2021, 6:46 PM
fbsd-phab_maskray.me added reviewers for D32524: rtld: Support DT_RELR relative relocation format: kib, emaste.
Oct 16 2021, 6:44 PM
fbsd-phab_maskray.me requested review of D32524: rtld: Support DT_RELR relative relocation format.
Oct 16 2021, 6:43 PM

Aug 27 2021

fbsd-phab_maskray.me added a comment to D31698: powerpc64*: fix for broken binaries generated by llvm12.

This is not suitable for the upstream. The root cause behind dso_local needs to be found and fixed.

Aug 27 2021, 3:34 PM · PowerPC

Aug 16 2021

fbsd-phab_maskray.me added a comment to D31498: rtld: Round down relro_size.

(FreeBSD on non-FreeBSD isn't smooth. i cannot do a build test.)

@fbsd-phab_maskray.me Could you post the error message somewhere? In general, cross-builds from linux+macOS should work, and I try to fix them after any breaking change.

Aug 16 2021, 5:29 PM
fbsd-phab_maskray.me added a comment to D31541: Combined D31538 and D31539 plus some more.

Thanks:)

Aug 16 2021, 4:42 PM

Aug 15 2021

fbsd-phab_maskray.me added a comment to D31541: Combined D31538 and D31539 plus some more.

D31538 is a functional change. I think it'd be good not to fix functional change without unrelated cleanups.

Aug 15 2021, 5:12 AM
fbsd-phab_maskray.me accepted D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Aug 15 2021, 5:11 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

fix the condition

Aug 15 2021, 3:51 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

actually default to true

Aug 15 2021, 3:47 AM
fbsd-phab_maskray.me added a comment to D31541: Combined D31538 and D31539 plus some more.

FWIW TLS_BELOW_TP and TLS_ABOVE_TP are more descriptive. VARIANT_I and VARIANT_II are less clear. In addition, technically arm/aarch64 are not strict Variant I because of the 2 reserved words. mips/powerpc are not strict Variant I because of a non-zero DTP offset. FreeBSD doesn't support the strict Variant I architectures (e.g. Alpha, ia64)

Aug 15 2021, 3:40 AM
fbsd-phab_maskray.me added a comment to D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
In D26352#711126, @kib wrote:

Dynamic linker itself is just an example of the breakage. There are more problems with e.g. libc/libthr, and this is only the base system. I do not know how much and where other problems are, in real world.

More, what users would do with this env var? They see that an app does not work, so what is next? How could they know that the env var needs to be set and _this_ is the cause of the breakage. And note that the variable must be ignored for setuid/setgid images.

So it cannot be handled this way.

I think your patch might be useful for experimentation, if you flip the meaning of the env var. That is, instead of making default standard-compliant, keep it as is. If the var is set, switch to desired behavior. Then we can commit this and some users would help us with evaluating the scope of the problem. In fact, I think this is a good first step.

Aug 15 2021, 3:36 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

Disable by default

Aug 15 2021, 3:35 AM

Aug 14 2021

fbsd-phab_maskray.me updated the diff for D31539: rtld: Remove calculate_tls_end.

Simplify allocate_tls

Aug 14 2021, 4:19 PM
fbsd-phab_maskray.me requested review of D31539: rtld: Remove calculate_tls_end.
Aug 14 2021, 6:00 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

add doc

Aug 14 2021, 5:30 AM
fbsd-phab_maskray.me retitled D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0 from Don't allow strong symbols to override weak ones for lookups to rtld: Don't allow strong symbols to override weak ones for lookups.
Aug 14 2021, 4:56 AM
fbsd-phab_maskray.me updated the summary of D31538: rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0.
Aug 14 2021, 4:05 AM
fbsd-phab_maskray.me requested review of D31538: rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0.
Aug 14 2021, 3:55 AM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Aug 14 2021, 12:07 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

You may use git commit --amend --author='Fangrui Song <i@maskray.me>'

Aug 14 2021, 12:04 AM

Aug 11 2021

fbsd-phab_maskray.me added a comment to D31498: rtld: Round down relro_size.
In D31498#710053, @kib wrote:

I do not understand this patch.

If linker specified that the end of relro is in the middle of some page, this means that there are relocations targeting that page. If we truncate relro_size, then relocation processing would operate on ro mapping and get SIGBUS/SIGSEGV.

Aug 11 2021, 5:14 PM
fbsd-phab_maskray.me updated the diff for D31498: rtld: Round down relro_size.

(FreeBSD on non-FreeBSD isn't smooth. i cannot do a build test.)

Aug 11 2021, 7:12 AM
fbsd-phab_maskray.me requested review of D31498: rtld: Round down relro_size.
Aug 11 2021, 6:58 AM

Aug 7 2021

fbsd-phab_maskray.me added a comment to D26514: gitignore: Add compile_commands.json.

I want to read some rtld-elf and libc code on Linux. I cannot run buildworld but want to generate a compile_commands.json to make my ccls happy. What should I do?

Aug 7 2021, 2:51 AM

Aug 6 2021

fbsd-phab_maskray.me added a comment to D23652: Handle non-plt IRELATIVE relocations..
In D23652#708723, @kib wrote:

Where do you think R_*_IRELATIVE should reside in? .rela.dyn or .rela.plt?

GNU ld's x86 port picks .rela.plt for https://sourceware.org/bugzilla/show_bug.cgi?id=13302
which may be related to this sentence "This may work on x86_64 where the R_*_IRELATIVE relocations happen in DT_JMPREL after the DT_REL* relocations, but that is no guarantee that it will work on AArch64, PPC64, or other architectures that are slightly different" on https://sourceware.org/glibc/wiki/GNU_IFUNC

For us it should not make a difference. We process whole DT_RELA while looking for IRELATIVE.

Aug 6 2021, 7:58 PM
fbsd-phab_maskray.me added a comment to D23652: Handle non-plt IRELATIVE relocations..

Where do you think R_*_IRELATIVE should reside in? .rela.dyn or .rela.plt?

Aug 6 2021, 8:05 AM

Feb 15 2021

fbsd-phab_maskray.me added inline comments to D24366: Align initial-exec TLS segments to the p_vaddr % align..
Feb 15 2021, 4:53 AM

Jan 31 2021

fbsd-phab_maskray.me added inline comments to D24366: Align initial-exec TLS segments to the p_vaddr % align..
Jan 31 2021, 5:48 PM
pi renamed fbsd-phab_maskray.me from i_maskray.me to fbsd-phab_maskray.me.
Jan 31 2021, 5:42 PM

Jan 29 2021

fbsd-phab_maskray.me added inline comments to D24366: Align initial-exec TLS segments to the p_vaddr % align..
Jan 29 2021, 8:23 PM

Oct 6 2020

fbsd-phab_maskray.me accepted D26647: Implement ptsname_r..
Oct 6 2020, 11:47 PM

Oct 4 2020

fbsd-phab_maskray.me accepted D26647: Implement ptsname_r..
Oct 4 2020, 5:24 AM

Oct 3 2020

fbsd-phab_maskray.me accepted D26647: Implement ptsname_r..
Oct 3 2020, 6:09 AM
fbsd-phab_maskray.me added inline comments to D26647: Implement ptsname_r..
Oct 3 2020, 4:29 AM

Sep 8 2020

fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 8 2020, 3:41 AM
fbsd-phab_maskray.me updated the diff for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.

Fix all STB_WEAK occurrences

Sep 8 2020, 3:38 AM

Sep 7 2020

fbsd-phab_maskray.me added a comment to D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
In D26352#585872, @kib wrote:

This breaks FreeBSD. If you look at the deleted block, the deleted comment explains why (and this is only one instance of it, there are more).

Sep 7 2020, 6:41 PM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:40 PM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:39 PM
fbsd-phab_maskray.me added reviewers for D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0: kib, bdragon, kan.
Sep 7 2020, 5:37 PM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:36 PM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:36 PM
fbsd-phab_maskray.me updated the summary of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:35 PM
fbsd-phab_maskray.me requested review of D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0.
Sep 7 2020, 5:30 PM
fbsd-phab_maskray.me added a comment to D23869: amd64 atomic.h: minor codegen optimization in flag access.

This has been supported since GCC 6/clang 9 (https://reviews.llvm.org/D57394). It would be better if the logic were conditioned on __GCC_ASM_FLAG_OUTPUTS__.

Sep 7 2020, 4:40 PM

Mar 21 2020

fbsd-phab_maskray.me added a comment to D24109: [LLVM][PPC32] Backport LLVM D75394.

I am hoping an administrator can change my username to something else. I don't want to expose my email address this way.

Mar 21 2020, 12:37 AM · PowerPC

Mar 4 2020

fbsd-phab_maskray.me added a comment to D23952: Link stand/i386 components using a linker script.

I really hope some administrator can change my username to something more sensible.

Mar 4 2020, 6:49 AM

Feb 23 2020

fbsd-phab_maskray.me accepted D23778: [PowerPC] Fix LLD10 linking of ofw loader on ppc.

Looks good.

Feb 23 2020, 6:43 PM · PowerPC

Sep 6 2019

fbsd-phab_maskray.me added a comment to D21163: Make p_vaddr % p_align == p_offset % p_align for TLS segments..
In D21163#465743, @kib wrote:
In D21163#464395, @i_maskray.me wrote:

...
Experiment with a few different alignments

Is that what you mean ?

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 9db4259be49..b8b154d1f32 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2236,12 +2236,14 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
       // p_align for dynamic TLS blocks (PR/24606), FreeBSD rtld has the same
       // bug, musl (TLS Variant 1 architectures) before 1.1.23 handled TLS
       // blocks correctly. We need to keep the workaround for a while.
+#if 0
       else if (Out::tlsPhdr && Out::tlsPhdr->firstSec == p->firstSec)
         cmd->addrExpr = [] {
           return alignTo(script->getDot(), config->maxPageSize) +
                  alignTo(script->getDot() % config->maxPageSize,
                          Out::tlsPhdr->p_align);
         };
+#endif
       else
         cmd->addrExpr = [] {
           return alignTo(script->getDot(), config->maxPageSize) +

?

Sep 6 2019, 5:56 AM
fbsd-phab_maskray.me added a comment to D21476: [PowerPC] force applications linked with lib CSU to have .got.

Can you instead add something like the following to crt1.c?

#if !defined(GCRT) && !defined(PIC)
__asm__(".text\n"
             "\t.global _GLOBAL_OFFSET_TABLE\n"
            "\t.reloc 0, R_PPC_NONE, _GLOBAL_OFFSET_TABLE_");
#endif
Sep 6 2019, 5:46 AM

Aug 21 2019

fbsd-phab_maskray.me added a comment to D21163: Make p_vaddr % p_align == p_offset % p_align for TLS segments..

Local-Exec TP offsets are link-time constants, and thus contracts between ld and ld.so. It may be worth checking if rtld-elf computed Local-Exec TP offsets match lld.

Aug 21 2019, 4:22 AM

Jul 27 2018

fbsd-phab_maskray.me added a comment to D16451: Improve --strip-trailing-cr handling.
Jul 27 2018, 3:16 AM
fbsd-phab_maskray.me accepted D16451: Improve --strip-trailing-cr handling.
Jul 27 2018, 2:51 AM