By: Etienne Lorrain (etienne_lorrain.delete@this.yahoo.fr), July 23, 2021 1:40 am
Room: Moderated Discussions
A bit related to my answer https://www.realworldtech.com/forum/?threadid=202614&curpostid=202635 , should we add variable length signature like for function (see https://en.wikipedia.org/wiki/Type_signature ) to encode the length of variables (in their symbol name, invisible in the language) and increase security against overflow?
I am more thinking of the C language, but it could work for others too.
As an example, "struct { int a,b,c,d; } mystruct;" would have the assembly symbol "mystruct$16".
C pointers and manual memory allocation would not be protected, unless there were a way to encode types like "pointer to 3 words", like:
int *pointer asm ("pointer$12") = malloc(12);
Then it would generate warnings/errors to have another pointer scanning the string and going off by one, or allocate 10 bytes for a pointer of 11 bytes when pointer is "signed". Maybe even runtime link errors if using a library where a structure was smaller.
What would be the problems with that? It looks to me like it should be backward compatible...
I am more thinking of the C language, but it could work for others too.
As an example, "struct { int a,b,c,d; } mystruct;" would have the assembly symbol "mystruct$16".
C pointers and manual memory allocation would not be protected, unless there were a way to encode types like "pointer to 3 words", like:
int *pointer asm ("pointer$12") = malloc(12);
Then it would generate warnings/errors to have another pointer scanning the string and going off by one, or allocate 10 bytes for a pointer of 11 bytes when pointer is "signed". Maybe even runtime link errors if using a library where a structure was smaller.
What would be the problems with that? It looks to me like it should be backward compatible...
Topic | Posted By | Date |
---|---|---|
Should variable symbols be "signed" with their length in bytes? | Etienne Lorrain | 2021/07/23 01:40 AM |
Should variable symbols be "signed" with their length in bytes? | gpd | 2021/07/23 01:55 AM |
Lipstick on a very old pig | Oink | 2021/07/23 02:44 AM |
Should variable symbols be "signed" with their length in bytes? | Andrey | 2021/07/23 05:15 AM |
Should variable symbols be "signed" with their length in bytes? | Doug S | 2021/07/23 08:14 AM |
Custom ELF section? | Mark Roulo | 2021/07/23 09:54 AM |
Should variable symbols be "signed" with their length in bytes? | Foo_ | 2021/07/23 11:19 PM |
Should variable symbols be "signed" with their length in bytes? | Ian Ameline | 2021/07/24 08:32 AM |
Should variable symbols be "signed" with their length in bytes? | dmcq | 2021/07/24 02:03 PM |