aboutsummaryrefslogtreecommitdiffhomepage
path: root/obj
diff options
context:
space:
mode:
Diffstat (limited to 'obj')
-rw-r--r--obj/elf.c14
-rw-r--r--obj/obj.c7
-rw-r--r--obj/obj.h1
3 files changed, 22 insertions, 0 deletions
diff --git a/obj/elf.c b/obj/elf.c
index d889fdd..5578452 100644
--- a/obj/elf.c
+++ b/obj/elf.c
@@ -87,6 +87,20 @@ enum {
BSS_SHNDX = 4,
};
+enum section
+elfhassym(const char *nam)
+{
+ struct sym *sym = findsym(str2idx(nam));
+ if (sym) switch (sym->shndx) {
+ case SHN_UND: return Snone;
+ case TEXT_SHNDX: return Stext;
+ case RODATA_SHNDX: return Srodata;
+ case DATA_SHNDX: return Sdata;
+ case BSS_SHNDX: return Sbss;
+ }
+ return Snone;
+}
+
void
elfaddsym(const char *nam, int info, enum section sect, uvlong value, uvlong size)
{
diff --git a/obj/obj.c b/obj/obj.c
index b9e2c79..fa62e9e 100644
--- a/obj/obj.c
+++ b/obj/obj.c
@@ -6,6 +6,7 @@
void elfinit(void);
+enum section elfhassym(const char *);
void elfaddsym(const char *, int info, enum section, uvlong value, uvlong size);
void elfreloc(const char *sym, enum relockind, enum section, uint off, vlong addend);
void elffini(struct wbuf *);
@@ -38,6 +39,12 @@ objdeffunc(const char *nam, bool globl, uint off, uint siz)
}
}
+enum section
+objhassym(const char *name)
+{
+ return elfhassym(name);
+}
+
uint
objnewdat(const char *name, enum section sec, bool globl, uint siz, uint align)
{
diff --git a/obj/obj.h b/obj/obj.h
index 235ab4d..8e9dea8 100644
--- a/obj/obj.h
+++ b/obj/obj.h
@@ -23,6 +23,7 @@ enum section { Snone, Stext, Srodata, Sdata, Sbss };
void objini(const char *infile, const char *outfile);
void objdeffunc(const char *nam, bool globl, uint off, uint siz);
+enum section objhassym(const char *name);
uint objnewdat(const char *name, enum section, bool globl, uint siz, uint align);
void objreloc(const char *sym, enum relockind, enum section, uint off, vlong addend);
void objfini(void);