--- Log opened Wed Nov 11 00:00:04 2015 | ||
olofk | I'm really really bad at C | 06:53 |
---|---|---|
olofk | Trying to add some stuff to the elf-loader, but it gives me 'implicit declaration of function' when I try to use a function from libelf | 06:54 |
olofk | But it's not complaining on the other functions | 06:54 |
olofk | oh... | 06:55 |
olofk | Apparently C is sensitive to spelling | 06:55 |
jkent | :) | 06:56 |
stekern | what? aren't you writing code in word, so you get spell correction? | 06:58 |
stekern | no joking though, I've seen it happen in real life | 06:59 |
stekern | inhereted an old 8051 asm project where the source was a .doc, with macro fields to automatically update a string with a date ;) | 07:01 |
olofk | stekern: woah.... that's really really scary | 07:01 |
olofk | Actually... that might be the worst thing I've heard. Can't think of anything that comes close | 07:01 |
olofk | How is elf_getident supposed to work? I've blindly tried all combinations of &, *, defining char* or char [] without success | 09:37 |
andrzejr | stekern, but you get a built-in revision control ;-) | 09:41 |
olofk | Anyone up for a quick review? Would be good to get some comments from an actual C coder :) | 10:02 |
GeneralStupid | olofk: ill try :) | 10:02 |
olofk | http://pastebin.com/fzYBABJp | 10:04 |
olofk | Tested it with picorv32 (Little Endian) in Verilator and mor1kx-generic (Big endian) in Verilator | 10:05 |
olofk | Works fine with mor1kx-generic in Icarus too, so the VPI stuff seems to be holding up | 10:06 |
olofk | and modelsim | 10:06 |
olofk | I considered using the conversion functions from endian.h in read_32, but I couldn't figure out which one to use. Endian conversions is a mess | 10:07 |
GeneralStupid | olofk: i think you should use {} in line 26 and the following lines | 10:12 |
GeneralStupid | olofk: its no problem, just consistency in setting curled bracktes | 10:13 |
GeneralStupid | you hate thes brackets, dont you? | 10:14 |
GeneralStupid | {} <3 | 10:14 |
GeneralStupid | olofk: one thing which may be a real reason is, you should use uint8_t types instead of char | 10:16 |
olofk | GeneralStupid: I was a bit careless with the indentation and bracketing | 10:18 |
olofk | But regarding char/uint8_t, elf_getident returns a char *, so I guess that's what I should use | 10:19 |
GeneralStupid | olofk: thats just a personal thing | 10:19 |
GeneralStupid | olofk: i already saw plattforms where char is signed 8 bit or unsigned 8 bit | 10:20 |
GeneralStupid | olofk: but if they return this they hopefully take care of the different compilers :) | 10:20 |
olofk | I was a bit worried about using a global variable for the endianness. Is that ok? | 10:23 |
GeneralStupid | iam a fan of types.h but due to the fact that getident is a systemcall... | 10:23 |
GeneralStupid | it is only set when loading an elf file? | 10:24 |
olofk | yes | 10:25 |
GeneralStupid | i think in that case its no problem. | 10:27 |
GeneralStupid | if you are scared about that, you could do that check twice | 10:29 |
olofk | I'm not that worried about the two functions will be called in the wrong order, but I'm not sure about what happens with global variables in a shared library, in case someone uses several instances | 10:31 |
GeneralStupid | no but it is ok. You load a file, then you read that file. There will be no concurrency in that | 10:31 |
olofk | Thanks. gtg | 10:32 |
GeneralStupid | olofk: no problem. If anyone changes your internal variable he should live with the results :-D | 10:34 |
_franck_ | olofk: line 48: if(big_endian) space after "if" | 11:01 |
olofk | ok, you had your chances. I'm pushing now | 12:09 |
stekern | do you have to make a global bigendian variable? | 12:12 |
stekern | too lazy too open the actual file and check | 12:12 |
olofk | stekern: Too lazy to implement it another way :) | 12:13 |
olofk | I could add endianness as a parameter to the read_32 function instead, but then I would break API. | 12:13 |
olofk | I think verilator_tb_utils and the vpi_wrapper are the only users, so it's not that big change, but this was quicker | 12:14 |
_franck_ | olofk: too bad you miss some spaces line 194 "address+3" | 12:46 |
olofk | _franck_: Are you sure? Look again | 12:49 |
GeneralStupid | stekern: i think its fine this way. global variables are stupid, redundant checks too ... so, you need to do it any way | 14:00 |
-!- knz_ is now known as knz | 14:34 | |
-!- heroux_ is now known as heroux | 16:17 | |
_franck_ | olofk: :) | 18:53 |
--- Log closed Thu Nov 12 00:00:06 2015 |
Generated by irclog2html.py 2.15.2 by Marius Gedminas - find it at mg.pov.lt!