[09/11] alloc_buffer: Apply asm redirection before first use
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Compilers may not be able to apply asm redirections to functions after
these functions are used for the first time, e.g. clang 13.
---
include/alloc_buffer.h | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
Comments
On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>Compilers may not be able to apply asm redirections to functions after
>these functions are used for the first time, e.g. clang 13.
You may say "clang 15". (clang 15.0.x has been released and clang still doesn't support this.
I think this is very difficult to support.... https://maskray.me/blog/2021-10-10-when-can-glibc-be-built-with-clang#asm-label-after-first-use
"Clang's one-function-at-a-time parsing and code generation strategy.")
Thanks. This fixed
In file included from mntent.c:21:
../include/allocate_once.h:92:20: error: cannot apply asm label to function after its first use
libc_hidden_proto (__libc_allocate_once_slow)
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'
# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
~~~~~~~~~~~~~~^~~~~~~~~~~~~~
./../include/libc-symbols.h:513:19: note: expanded from macro 'hidden_proto'
__hidden_proto (name, , __GI_##name, ##attrs)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:519:33: note: expanded from macro '__hidden_proto'
extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Reviewed-by: Fangrui Song <maskray@google.com>
On 28/10/22 21:32, Fangrui Song wrote:
> On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>> Compilers may not be able to apply asm redirections to functions after
>> these functions are used for the first time, e.g. clang 13.
Ack.
>
> You may say "clang 15". (clang 15.0.x has been released and clang still doesn't support this.
> I think this is very difficult to support.... https://maskray.me/blog/2021-10-10-when-can-glibc-be-built-with-clang#asm-label-after-first-use
> "Clang's one-function-at-a-time parsing and code generation strategy.")
>
>
> Thanks. This fixed
> > In file included from mntent.c:21:
> ../include/allocate_once.h:92:20: error: cannot apply asm label to function after its first use
> libc_hidden_proto (__libc_allocate_once_slow)
> ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
> ./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'
> # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
> ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
> ./../include/libc-symbols.h:513:19: note: expanded from macro 'hidden_proto'
> __hidden_proto (name, , __GI_##name, ##attrs)
> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./../include/libc-symbols.h:519:33: note: expanded from macro '__hidden_proto'
> extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
>
> Reviewed-by: Fangrui Song <maskray@google.com>
Thanks.
@@ -114,6 +114,9 @@ enum
/* Internal function. Terminate the process using __libc_fatal. */
void __libc_alloc_buffer_create_failure (void *start, size_t size);
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_alloc_buffer_create_failure)
+#endif
/* Create a new allocation buffer. The byte range from START to START
+ SIZE - 1 must be valid, and the allocation buffer allocates
@@ -132,6 +135,9 @@ alloc_buffer_create (void *start, size_t size)
/* Internal function. See alloc_buffer_allocate below. */
struct alloc_buffer __libc_alloc_buffer_allocate (size_t size, void **pptr)
__attribute__ ((nonnull (2)));
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_alloc_buffer_allocate)
+#endif
/* Allocate a buffer of SIZE bytes using malloc. The returned buffer
is in a failed state if malloc fails. *PPTR points to the start of
@@ -333,6 +339,9 @@ void * __libc_alloc_buffer_alloc_array (struct alloc_buffer *buf,
size_t size, size_t align,
size_t count)
__attribute__ ((nonnull (1)));
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_alloc_buffer_alloc_array)
+#endif
/* Obtain a TYPE * pointer to an array of COUNT objects in BUF of
TYPE. Consume these bytes from the buffer. Return NULL and mark
@@ -349,6 +358,9 @@ void * __libc_alloc_buffer_alloc_array (struct alloc_buffer *buf,
struct alloc_buffer __libc_alloc_buffer_copy_bytes (struct alloc_buffer,
const void *, size_t)
__attribute__ ((nonnull (2)));
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_alloc_buffer_copy_bytes)
+#endif
/* Copy SIZE bytes starting at SRC into the buffer. If there is not
enough room in the buffer, the buffer is marked as failed. No
@@ -363,6 +375,9 @@ alloc_buffer_copy_bytes (struct alloc_buffer *buf, const void *src, size_t size)
struct alloc_buffer __libc_alloc_buffer_copy_string (struct alloc_buffer,
const char *)
__attribute__ ((nonnull (2)));
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_alloc_buffer_copy_string)
+#endif
/* Copy the string at SRC into the buffer, including its null
terminator. If there is not enough room in the buffer, the buffer
@@ -377,12 +392,4 @@ alloc_buffer_copy_string (struct alloc_buffer *buf, const char *src)
return result;
}
-#ifndef _ISOMAC
-libc_hidden_proto (__libc_alloc_buffer_alloc_array)
-libc_hidden_proto (__libc_alloc_buffer_allocate)
-libc_hidden_proto (__libc_alloc_buffer_copy_bytes)
-libc_hidden_proto (__libc_alloc_buffer_copy_string)
-libc_hidden_proto (__libc_alloc_buffer_create_failure)
-#endif
-
#endif /* _ALLOC_BUFFER_H */