There is a lot to unpack here, so please forgive me while I try to format this in a readable and concise way.
[Patch 1/5]
I thought this was already submitted and merged in? It looks identical to "[PATCH v2] static pie: building static PDE", or am I mistaken?
[Patch 2/5]
I'm going to be honest with you, I left that check out because it only affects xtensia, so it's funny to me that it would bite me this quickly. That said, reading the code, I'm not sure why xtensia decided to call elf_machine_relative in PERFORM_BOOTSTRAP_GOT and not use the default code path with ELF_MACHINE_PLTREL_OVERLAP set to ensure only 1 iteration. I am not very familiar with xtensia, so there may be some nuance that I'm not aware of, but I would like your opinion on if we should change xtensia to conform to how every other architecture seems to perform that relocation.
If we are going to keep the code the way it is, I would like to know everyone's opinion on whether or not we should change that preprocessor directive to be explicit on which architectures shouldn't do that section of code? Currently it's in an allow list format with seemingly only xtensia having a false condition, but that isn't very clear to me from an initial read. Obviously that change would belong to a separate patch and shouldn't hold this up.
[Patch 3/5]
looks good to me.
[Patch 4/5]
I think this removal further implies that we should move the elf_machine_relative call out of PERFORM_BOOTSTRAP_GOT as I suggested above.
[Patch 5/5]
I am getting segfaults while still in __uClibc_main when using buildroot's qemu_xtensa_lx60_defconfig and qemu-xtensa. I'm not sure the exact cause, but I would guess that some functions aren't being relocated correctly or the TLS wasn't updated correctly. It could also possibly be a problem with the quick gcc patch I wrote to compile with -static-pie. If you have a gcc patch that you think will fix this as well, I would be glad to test it.
Here is the stack trace up to where it calls 0x00:
#0 0x3efe58e9 in __h_errno_location () at libpthread/nptl/herrno.c:33
#1 0x3efe12aa in __uClibc_main (main=0x3efddfbc <main>, argc=0x1, argv=0x3efdb314, app_init=0x3efdde14 <_init>, app_fini=0x3eff5864 <_fini>, rtld_fini=0x0, stack_end=0x3efdb310) at libc/misc/internals/__uClibc_main.c:514
#2 0x3efdde6c in _start ()