Skip to content

Commit

Permalink
Merge pull request #3631 from masatake/ldscript--revise-VERSION-parsing
Browse files Browse the repository at this point in the history
Ldscript:  improve tagging versions in VERSION commands
  • Loading branch information
masatake committed Jan 14, 2023
2 parents a421b6c + d9ca200 commit c39ff7a
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
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

0 comments on commit c39ff7a

Please sign in to comment.