• 32 Posts
  • 1.04K Comments
Joined 2 years ago
cake
Cake day: June 15th, 2023

help-circle



  • Your ld.so contains:

    Entry point address: 0x1d780

    EDIT: …with which I meant, modulo brainfart: My libc.so.6 contains a proper entry address, while other libraries are pointing at 0x0 and coredump when executed. libc.so is a linker script, presumably because GNU compulsively overcomplicates everything.

    …I guess that’s enough for the kernel. It might be a linux-only thing, maybe even unintended and well linux doesn’t break userspace.

    Speaking of, I was playing it a bit fast and loose: _start is merely the default symbol name for the entry label, I’m sure nasm and/or ld have ways to set it to something different.



  • How does executing a program actually work?

    Way too long an answer for a lemmy post

    It has an executable flag, but what actually happens in the OS when it encounters a file with an executable file?

    Depends on OS. Linux will look at the first bytes of the file, either see (ASCII) #! (called a shebang) or ELF magic, then call the appropriate interpreter with the executable as an argument. When executing e.g. python, it’s going to call /usr/bin/env with parameters python and the file name because the shebang was #!/usr/bin/env python.

    How does it know to execute “main”?

    Compiled C programs are ELF so it will go through the ELF header, figure out which ld.so to use, then start that so that it will find all the libraries, resolve all dynamic symbols, then do some bookkeeping, and jump to _start. That is, it doesn’t: main is a C thing.

    Is it possible to have a library that can be called and also executed like a program?

    Absolutely. ld.so is an example of that.. Actually, wait, I’m not so sure any more, I’m getting things mixed up with libdl.so. In any case ld.so is an executable with a file extension that makes it look like a library.

    EDIT: It does work. My (GNU) libc spits out version info when executed as an executable.

    If you want to start looking at the innards like that I would suggest starting here: Hello world in assembly. Note the absence of a main function, the symbol the kernel actually invokes is _start, the setup necessary to call a C main is done by libc.so. Don’t try to understand GNU’s libc it’s full of hystarical raisins I would suggest musl.






  • NixOS. Gentoo gets into trouble when you need multiple versions of the same library at the same time. Also while the infrastructure supports it it’s annoying that gentoo doesn’t provide pre-built binaries, like yes some people might want to have reason to build their own bash but I think I’ll be fine with a standard build. NixOS? If you install something usually it’s going to be pre-built. Change a couple of configuration flags? May or may not be pre-built. You want to apply a custom patch? It’s going to seamlessly build from source.


  • Not really, they’d clash all the time. 8080 is the default port for a non-privileged webserver, that is, web server, something you put your own stuff on, not applications/daemons that happen to have a web interface. E.g. ComfyUI uses 8188 for its web interface, deluge 8112, neither will serve your index.html.



  • 255, generally, because null termination. ZFS does 1023, the argument not being “people should have long filenames” but “unicode exists”, ReiserFS 4032, Reiser4 3976. Not that anyone uses Reiser, any more. Also Linux’ PATH_MAX of 4096 still applies. Though that’s in the end just a POSIX define, I’m not sure whether that limit is actually enforced by open(2)… man page speaks of ENAMETOOLONG but doesn’t give a maximum.

    It’s not like filesystems couldn’t support it it’s that FS people consider it pointless. ZFS does, in principle, support gigantic file metadata but using it would break use cases like having a separate vdev for your volume’s metadata. What’s the point of having (effectively) separate index drives when your data drives are empty.



  • I did try to find unit costs for Cuba’s vaccine but failed. While doing that I found a paper analysing distribution costs in Vietnam and long story short it can easily cost four bucks just to get the stuff from the plant into people’s arms.

    Not patenting it would allow them to create their own

    Patenting it and licensing it also allows them to create their own, but now they need a plant to do that, which requires things like reliable electricity, infrastructure to enable supply of raw materials, whatnot. It’s not like you can brew that kind of thing in a bathtub. What patenting also does is stop random Indian pharma producers from cooking it up and selling it to Botswana without giving you a cut, that is, the wrong private enterprise profiting off it. One that didn’t incur costs doing studies so that regulators would greenlight it.

    From what I gather most of the doses used overall in the world were AstraZeneca, and much of it was given to countries for free, with western countries stemming the bill, not AstraZeneca. The EU apparently (it’s in your wiki link) brought the price down to €1.78 because the EU was supplying the production capacity, and €12 for Pfizer/Biontech, which was never in the race for distribution to poor countries in the first place because it requires a tight, and very cool, cooling chain. Forget about the four bucks per dose for distribution in that case.


    Would this all have been better in a socialist world? Yes. But that’s not what the situation on the ground was during the pandemic so stop making the perfect the enemy of the good, western countries (excluding the US) were up to the task not getting fucked over by big pharma, and passed that on to other countries.




  • If you want a really advanced build system there’s shake, which can deal with things like building things that generates dependency information for things that build things. In a nutshell: It’s strictly more powerful than make because (a single invocation of) make operates on a fixed dependency graph while shake can discover dependencies as it goes.

    Mostly though you should use whatever comes with the language you’re using, and if you’re doing something simple use make. That includes “link a multi-language project where the components are generated by language-specific systems”. It notably doesn’t include multi-stage compiler builds. GHC switched from recursive make, which is a bad idea, to non-recursive make, which was… arcane, but at least you didn’t have to make clean to get a correct build, to shake. Here’s the build system it’s a whole project to itself.