Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix computing string length with indirect symbols from symbols files. #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rolfbjarne
Copy link

Indirect symbols are copied twice to the 'p' variable, this is the second time:

cctools/misc/strip.c

Lines 4217 to 4228 in cbe977a

if((n_type & N_TYPE) == N_INDR){
if(n_value != 0){
strcpy(p, strings + n_value);
if(object->mh != NULL)
new_symbols[inew_syms].n_value =
(uint32_t)(p - new_strings);
else
new_symbols64[inew_syms].n_value =
(uint32_t)(p - new_strings);
p += strlen(p) + 1;
}
}

This means we need to add the size of the indirect symbol to the size of the 'p' memory contents twice.

This seems to already be happening here:

cctools/misc/strip.c

Lines 3820 to 3823 in cbe977a

if((n_type & N_TYPE) == N_INDR){
len = strlen(strings + n_value) + 1;
new_ext_strsize += len;
}

and:

cctools/misc/strip.c

Lines 3845 to 3848 in cbe977a

if((n_type & N_TYPE) == N_INDR){
len = strlen(strings + n_value) + 1;
new_ext_strsize += len;
}

but one scenario (symbols files) was missing.

Ref: FB13327641 (contains test case).
Ref: dotnet/macios#19157

Indirect symbols are copied twice to the 'p' variable, this is the second time:

https://github.com/apple-oss-distributions/cctools/blob/cbe977a1db16a2ca268124f6825535aeb670404c/misc/strip.c#L4217-L4228

This means we need to add the size of the indirect symbol to the size of the 'p' memory contents twice.

This seems to already be happening here:

https://github.com/apple-oss-distributions/cctools/blob/cbe977a1db16a2ca268124f6825535aeb670404c/misc/strip.c#L3820-L3823

and:

https://github.com/apple-oss-distributions/cctools/blob/cbe977a1db16a2ca268124f6825535aeb670404c/misc/strip.c#L3845-L3848

but one scenario (symbols files) was missing.

Ref: FB13327641 (contains test case).
Ref: dotnet/macios#19157
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.

1 participant