Page MenuHomeFreeBSD

libc: add execvpe to weak symbol as gnu libc does
ClosedPublic

Authored by aokblast on Apr 9 2025, 1:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 26, 3:23 PM
Unknown Object (File)
Sun, Nov 16, 9:33 PM
Unknown Object (File)
Sun, Nov 16, 10:43 AM
Unknown Object (File)
Sun, Nov 16, 7:43 AM
Unknown Object (File)
Sun, Nov 16, 7:07 AM
Unknown Object (File)
Sun, Nov 16, 3:49 AM
Unknown Object (File)
Sun, Nov 16, 1:23 AM
Unknown Object (File)
Sat, Nov 15, 5:50 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 63634
Build 60518: arc lint + arc unit

Event Timeline

Why? Why does glibc do this?

jrm added a subscriber: jrm.

I think that the proper fix in line with the existing code is to use namespace.h to mangle execvpe reference in libc.

Use namespace.h instead of waek alias

The bear problem still fixed but we are unable to intercept the execvpe call as it is replaced with _execvpe.

In D49733#1134224, @kib wrote:

I think that the proper fix in line with the existing code is to use namespace.h to mangle execvpe reference in libc.

brooks requested changes to this revision.Apr 11 2025, 2:53 AM

I think you need to bring the __weak_reference line back from the original change.

Using _execvpe is consistent, but perhaps it should be __libc_execvpe. The general _<foo> model is a remnant of libc_r and should perhaps be removed at some point.

lib/libc/gen/Symbol.map
460 ↗(On Diff #153445)

You can't remove previously exported public symbols.

lib/libc/gen/exec.c
301

Remove

lib/libc/include/libc_private.h
358

Should not be required.

lib/libc/include/namespace.h
64–65 ↗(On Diff #153445)

White space is wrong and touching the execve line is bug.

More importantly, you're missing a matching un-namespace.h change.

This revision now requires changes to proceed.Apr 11 2025, 2:53 AM

You still need to add a an #undef execvpe line to un-namespace.h and then you shouldn't need the libc_private.h entry. The point of namespace.h/un-namespace.h is that the declarations are impacted by the macro so the execvpe declaration in unistd.h becomes an __libc_execvpe declaration which you can then use.

This revision is now accepted and ready to land.Apr 17 2025, 4:47 PM
lib/libc/include/namespace.h
65 ↗(On Diff #153542)

If you changed the original symbol name, why the namespacing is still kept in the patch?

I think it is for consistency as all standard C library call point to the actual implementation in namespace.h?

I think it is for consistency as all standard C library call point to the actual implementation in namespace.h?

No, you do not namespace execvpe, instead you use explicit internal symbol. So I do not think there is a point in changing namespace.h.

Sorry for the churn, but I think @kib is right and this should be declared in libc_private.h and not namespaced.

Delete namespace and un-namespace stuff

This revision now requires review to proceed.Apr 22 2025, 4:19 PM
This revision is now accepted and ready to land.Apr 22 2025, 4:32 PM

If someone want to help me merge this patch. Please use the following commit on github:
https://github.com/aokblast/freebsd-src/commit/fd54c46f55ebd500bd7bf2380bacd818b4784059

lib/libc/include/libc_private.h
358

I think this should be above __libc_sigaction with no line break so they are alphabetical (modulo prefix)

This revision now requires review to proceed.Apr 22 2025, 4:40 PM

LGTM with @brooks's comment incorporated. I can grab the change from GitHub, fold in that change, and push.

This revision is now accepted and ready to land.Apr 22 2025, 4:44 PM

there are some typo Sponrored->Sponsored in commit message. @emaste Could you please help me to fix it when committing?

Yeah, I already spotted and corrected that. I was editing the message to add kib to the reviewed-by list before noticing that it was already there.

This revision was automatically updated to reflect the committed changes.