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

Ldscript: improve tagging versions in VERSION commands #3631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Units/parser-ldscript.r/anon-version.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
4 changes: 4 additions & 0 deletions Units/parser-ldscript.r/anon-version.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jiffies input.lds /^jiffies = jiffies_64;$/;" s
verd85df1730102 input.lds /^ {$/;" v
__executable_start input.lds /^ PROVIDE (__executable_start = START);$/;" s assignment:provide
__binary_start input.lds /^ __binary_start = START;$/;" s
28 changes: 28 additions & 0 deletions Units/parser-ldscript.r/anon-version.d/input.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Taken from linux/arch/um/kernel/uml.lds.S */
/* SPDX-License-Identifier: GPL-2.0 */
#include <asm/vmlinux.lds.h>
#include <asm/page.h>

OUTPUT_FORMAT(ELF_FORMAT)
OUTPUT_ARCH(ELF_ARCH)
ENTRY(_start)
jiffies = jiffies_64;

VERSION {
{
local: *;
};
}

SECTIONS
{
/* This must contain the right address - not quite the default ELF one.*/
PROVIDE (__executable_start = START);
/* Static binaries stick stuff here, like the sigreturn trampoline,
* invisibly to objdump. So, just make __binary_start equal to the very
* beginning of the executable, and if there are unmapped pages after this,
* they are forever unusable.
*/
__binary_start = START;
/* ... */
}
1 change: 1 addition & 0 deletions Units/parser-ldscript.r/multi-versions.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
3 changes: 3 additions & 0 deletions Units/parser-ldscript.r/multi-versions.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VERS_1.1 input.lds /^ VERS_1.1 {$/;" v
VERS_1.2 input.lds /^ VERS_1.2 {$/;" v
VERS_2.0 input.lds /^ VERS_2.0 {$/;" v
23 changes: 23 additions & 0 deletions Units/parser-ldscript.r/multi-versions.d/input.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Taken from info manual of ld */
VERSION {
VERS_1.1 {
global:
foo1;
local:
old*;
original*;
new*;
};

VERS_1.2 {
foo2;
} VERS_1.1;

VERS_2.0 {
bar1; bar2;
extern "C++" {
ns::*;
"f(int, double)";
};
} VERS_1.2;
}
20 changes: 19 additions & 1 deletion parsers/ldscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,30 @@ static void parseVersions (tokenInfo *const token)
tokenRead (token);
if (token->type == '{')
{
tokenInfo *curly = newTokenByCopying(token);
tokenRead (token);
if (token->type == '{')
{
vString *anonver = anonGenerateNew ("ver", K_VERSION);
makeSimpleTag (anonver, K_VERSION);
vStringDelete(anonver);
tokenUnread (token);
tokenSkipOverPair (curly);
tokenCopy (token, curly);
tokenDelete (curly);
return;
}
tokenDelete (curly);
tokenUnread (token);

do {
tokenRead (token);
if (tokenIsType(token, IDENTIFIER))
{
parseVersion (token);
tokenSkipToType (token, ';');
}
} while (! (tokenIsEOF (token) || token->type == '}'));
tokenSkipToType (token, ';');
}
}

Expand Down