C++ Logo


Advanced search

Re: [SG16] A UTF-8 environment specification; an alternative to assuming UTF-8 based on choice of literal encoding

From: Isabella Muerte <imuerte_at_[hidden]>
Date: Fri, 30 Jul 2021 09:55:31 -0700
On Fri, Jul 30, 2021, at 09:39, Thiago Macieira via SG16 wrote:
> On Friday, 30 July 2021 09:31:19 PDT Tom Honermann wrote:
> > Indeed. My use case was trying to get them before main().
> You can use _dl_argc and _dl_argv (glibc specific) and _environ. The argv is
> always just below _environ, so you can know where it ends, but finding where
> it starts is a little more difficult if you don't have argc too.

There are easier ways as well for ELF (modern loader implementations) and MACH-O based platforms. Placing a function pointer into the .init_array for ELF and __mod_init_func on MACH-O allows you to set argc and argv to variables you control.

I did this for the initial implementation of P1275’s std::arguments type back in 2018.


> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
> --
> SG16 mailing list
> SG16_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/sg16

Received on 2021-07-30 11:55:55