Skip to content

fix signature of _lseek() stub#775

Open
A-Dunstan wants to merge 1 commit intoPaulStoffregen:masterfrom
A-Dunstan:fix_lseek_signature
Open

fix signature of _lseek() stub#775
A-Dunstan wants to merge 1 commit intoPaulStoffregen:masterfrom
A-Dunstan:fix_lseek_signature

Conversation

@A-Dunstan
Copy link
Contributor

@A-Dunstan A-Dunstan commented Feb 1, 2025

The function signature for the default _lseek stub is incorrect, the second parameter should be a signed 32-bit value rather than 64-bits. The incorrect signature triggers a warning when the stub is replaced with a proper _lseek function (with correct signature, since the arguments aren't interpreted correctly with the bad one) and LTO is used.


__attribute__((weak))
int _lseek(int fd __attribute__((unused)), long long offset __attribute__((unused)), int whence __attribute__((unused)))
off_t _lseek(int fd __attribute__((unused)), off_t offset __attribute__((unused)), int whence __attribute__((unused)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the file should also include <sys/types.h>.
Ref: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally all the weak functions should be in a separate file (syscalls.c?) since startup.c isn't really a suitable place for them, but I was going for brevity in the hopes of a quick merge...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the definition of off_t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants