<sorear>
for SLEB128 you can do temp += (byte < 64 ? byte : byte - 128) << shift;
<sorear>
then change 64 to 128 for ULEB128
OwlWizard has quit [Quit: OwlWizard]
<meowray>
sorear: ah yes. so, sleb128 (v < 64 ? v - 128 : v) wins?
JanC has quit [Ping timeout: 264 seconds]
<sorear>
it's enough of a wash that I'm not comfortable declaring that without a benchmark
<meowray>
v < 128 ? v < 64 ? v - 128 : v : slow(v); z < 128 ? (z >> 1) ^ -(z & 1) : slow(z); possibly better describes the one-byte fast path.
JanC has joined #riscv
JanC_ has joined #riscv
JanC is now known as Guest9757
Guest9757 has quit [Killed (molybdenum.libera.chat (Nickname regained by services))]
JanC_ is now known as JanC
<meowray>
zigzag is noticeably worse on x86, slightly worse on aarch64
<sorear>
musl dynlink code generally treats a missing DT_XXX the same as DT_XXX with val=0, which works for existing reloc types since SZ=0 -> that type of reloc isn't present
<sorear>
there's a secondary mechanism based on a bitmask for DT_XXX less than 32 :)
<sorear>
there doesn't seem to be anything preventing CREL from having a file virtual address of 0
<meowray>
the code uses dyn[DT_CRELSZ] for the relocation count. iirc, calloc in prepare_lazy can be replaced with calloc(n, 3). this is to work around some applications, so not supporting CREL should be acceptable
Trifton has joined #riscv
mlw has joined #riscv
BootLayer has joined #riscv
<meowray>
sorear: loop condition: byte >= 128. sleb_uleb cannot be used within the loop. outside the loop, do if (sign && byte & 64) tmp |= (size_t)-1 << shift;
fuwei has joined #riscv
junaid_ has joined #riscv
davidlt has joined #riscv
davidlt has quit [Remote host closed the connection]
davidlt has joined #riscv
naoki has joined #riscv
naoki has quit [Client Quit]
handsome_feng has joined #riscv
crossdev has joined #riscv
dh` has quit [Read error: Connection reset by peer]
khem has quit [Quit: Connection closed for inactivity]
bitoff has quit [Ping timeout: 260 seconds]
BootLayer has quit [Quit: Leaving]
luca_ has joined #riscv
crabbedhaloablut has quit []
JanC_ has joined #riscv
JanC has quit [Ping timeout: 260 seconds]
JanC_ is now known as JanC
luca_ is now known as OwlWizard
crabbedhaloablut has joined #riscv
bitoff has joined #riscv
bitoff has quit [Client Quit]
OwlWizard is now known as luca
luca is now known as Guest3597
handsome_feng has quit [Quit: Connection closed for inactivity]
davidlt has quit [Ping timeout: 252 seconds]
junaid_ has quit [Quit: Lost terminal]
khem has joined #riscv
Tenkawa has joined #riscv
Guest3597 is now known as OwlWizard
junaid_ has joined #riscv
taj has joined #riscv
taj has quit [Remote host closed the connection]
junaid_ has quit [Ping timeout: 264 seconds]
oaken-source has quit [Ping timeout: 264 seconds]
junaid_ has joined #riscv
oaken-source has joined #riscv
jn__ is now known as jn
BootLayer has joined #riscv
prabhakalad has quit [Quit: Konversation terminated!]
prabhakalad has joined #riscv
junaid_ has quit [Quit: Lost terminal]
elastic_dog has quit [Ping timeout: 245 seconds]
elastic_dog has joined #riscv
heat has joined #riscv
OwlWizard has quit [Quit: OwlWizard]
davidlt has joined #riscv
Leopold has quit [Ping timeout: 260 seconds]
Leopold has joined #riscv
junaid_ has joined #riscv
Stat_headcrabed has joined #riscv
psydroid has joined #riscv
balrog_ is now known as balrog
crossdev has quit [Remote host closed the connection]
EchelonX has joined #riscv
Guest95 has joined #riscv
Guest95 has quit [Client Quit]
___nick___ has joined #riscv
junaid_ has quit [Quit: Lost terminal]
junaid_ has joined #riscv
KREYREN has joined #riscv
heat has quit [Remote host closed the connection]
___nick___ has quit [Ping timeout: 245 seconds]
___nick___ has joined #riscv
<sorear>
meowray: i don't follow
<meowray>
sorear: get_leb128 is incorrect. (1) the loop stop condition is while (byte >= 128) (2) the use of sleb_uleb in the loop does not correctly handle sign extension
<sorear>
i grant that the loop condition is backward, when does it fail to correctly sign extend? (byte - 128*(byte >= 64)) only comes out negative if byte is [64,127], which is only possible for the last byte
Tenkawa has quit [Quit: Was I really ever here?]
khem has quit []
<meowray>
sorear: initial bytes can be in the range [64,128) as well, not just the last byte
khem has joined #riscv
<sorear>
meowray: what's an example of a leb128 sequence where a byte which is not the last byte is less than 128?
Leopold has quit [Ping timeout: 260 seconds]
<meowray>
sorear: sorry, my description of (2) is wrong. get_leb128 is correct once the loop condition is fixed
Leopold has joined #riscv
<meowray>
clever use of sleb_uleb!
<meowray>
i think `tmp |=` is more idiomatic than `tmp +=` ?
<sorear>
I couldn't say, although in the spirit of excessive cleverness ADD is likely to be shorter than OR on thumb or rvc
<sorear>
pretty sure they're the same on s390x, i386, and sh and I never bothered to learn microMIPS at that level
dh` has joined #riscv
<meowray>
i don't see a difference on godbolt using "ARM GCC thunk" -mthumb and "RISC-V rv64gc clang"
KREYREN has quit [Remote host closed the connection]