freenode/#sicl - IRC Chatlog
Search
5:31:16
beach
The article is from 2015 and claims to improve on Steele & White, on Clinger, and on Dybvig.
5:36:46
ck_
I'll atone for the mistake by posting a link to the paper, for the record: https://arxiv.org/pdf/1310.8121.pdf
5:55:58
beach
In case it is not clear, this suggestion is one in a collection of small projects that I have been asked to suggest by several people in order to facilitate contributions to SICL.
6:25:33
beach
There is of course also this (not so small) project that I would like to see worked on: metamodular.com/POSIX-API/
6:58:07
heisig
beach: I need to differentiate whether CST-to-AST is used by the file compiler or not. Only the former case requires hoisting of non-trivial constants.
7:25:32
beach
Thinking ahead a bit... I see this library: https://github.com/eschulte/elf for manipulating ELF files. Any opinions about it, or information about others?
7:47:34
heisig
One 'problem' could be that the library is GPL licensed. So using it would put SICL under GPL :)
7:49:52
heisig
Just saying. All in all, is great to see that there is already a library for handling ELF files.
8:39:48
beach
So the thing to do in order to test this library would be to write a Common Lisp program that creates a minimal ELF executable that just does a syscall of exit with some value greater than 0.
8:46:09
beach
Trying to figure out all the information that is required to make it work, like what sections are needed, what format they have etc.
8:49:14
beach
If I were to do it, I would probably write an assembly program, link it and see what sections are created. From GCC there is just way too much information present.
8:50:34
beach
Well, I managed to use the Common Lisp library "elf" to read an ELF executable, so I can use that.
8:53:54
beach
Of course I also forgot the NASM syntax, even though I have actually used it to write some test programs in the past.
9:21:48
beach
Well, this was precisely the kind of result that I feared. I made a 64-bit NASM program, turned it into a .o file, tried to link it, and ld says it's a 32-bit relocatable file. Reading it with the ELF Common Lisp library says it's a 64-bit file.
9:30:04
beach
I have a feeling that I must make my program start at this address, or else inform ld otherwise.
9:30:05
no-defun-allowed
Hm, isn't that supposed to be in the C runtime? start calls main and calls exit with main's return value I think.
9:30:58
no-defun-allowed
Yeah, in that case I believe your program's entry point has to be _start, not main or anything else.
9:34:02
beach
I mean, I don't know what I need to do to convince ld to treat my first instruction as the entry point.
9:34:40
ck_
https://stackoverflow.com/questions/17898989/what-is-global-start-in-assembly-language ?
9:34:45
no-defun-allowed
I can't remember nasm too well either, so I'm reading the Hello World example in https://jameshfisher.com/2018/03/10/linux-assembly-hello-world/
9:43:26
beach
So I guess the next step is to use the Common Lisp ELF library to see what sections can be removed without changing the program. Or I guess I could use sstrip.
10:05:12
beach
This wasn't too hard. Thanks for the help everyone. Perhaps by adding stuff to my 3-line assembly program (like data, etc) I can figure out what I absolutely need to supply in the ELF executable.
10:33:35
no-defun-allowed
Today I lost a week's worth of work cause I suck at git and I reset away all of it.
10:34:33
no-defun-allowed
Tried to undo a commit with some junk files by using `git reset --hard` and they're not in the FS.
10:39:14
ck_
if not, you were unlucky and the git gc ran in the meantime. I have recovered unlinked commits like that in the past, so it isn't out of the question in general
10:41:33
no-defun-allowed
Yeah, it's there, I tried to `git reset` to it and it gives me a list of unstaged changes and doesn't restore anything.
10:48:09
beach
Included the entire file in the data of the single section, so I got confused, because it contained more than the instructions.
11:30:21
beach
I am not sure why the Common Lisp ELF library includes sizes of various entries in the ELF file. I would assume that it could compute those.
11:31:45
beach
The question is whether client code must keep those slot values synchronized with the rest of the data. That would be too bad.
11:41:30
beach
I don't think I would have written the library this way. But it was probably partly written to examine all the fields and such in an ELF file.
15:13:02
beach
Argument parsing can be very complex, in particular in the presence of &REST and &KEY parameters. In some situations I need to call Common Lisp functions, like ERROR if there is a problem and CONS to create the &REST parameter.
15:13:15
beach
The code for argument parsing involves registers and arbitrary memory locations, so it does not belong in HIR.
15:13:22
beach
But introducing this code after HIR has been completely processed would be painful, because calling ERROR and CONS involves hoisting FDEFINITIONs and processing the resulting shared variables, something we have already done at the HIR level.
15:13:29
beach
So I came up with this solution: I am planning to introduce some new HIR instructions that take care of chunks of what is required to process arguments, like MORE-ARGUMENTS-LEFT-TO-PROCESS-P, DECREMENT-REMAINING-ARGUMENTS-POINTER, and the like.
15:13:32
beach
This way, I can introduce argument parsing before most HIR transformations happen without violating the invariant of HIR that only Common Lisp values are manipulated.
15:14:33
beach
I have not yet come up with a list of the exact instructions I need to introduce, but I will do that in the next few days.