Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
L llvm-project
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 31
    • Issues 31
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Morello
  • llvm-project
  • Issues
  • #39

Closed
Open
Created Oct 05, 2021 by Jessica Clarke@jrtc27Developer

STT_NOTYPE symbols with LSB set interfere with disassembly

	.global foo
	.type foo, %function
foo:
	nop
	nop
	.size foo, . - foo

When compiled and linked with -Wl,--defsym=bar=foo, disassembling gets confused by the STT_NOTYPE symbol with its LSB set, and tries to "re-align" itself with the symbol, breaking itself and ending up off by one:

Jessicas-MacBook-Pro:morello-defsym Jess% morello-llvm llvm-objdump -d foo                                                      

foo:	file format elf64-littleaarch64


Disassembly of section .text:

0000000000010260 <foo>:
   10260: 1f 20 03 d5  	nop

0000000000010261 <bar>:
   10261: 20 03 d5 1f  	<unknown>
   10265: 20 03 d5 00  	<unknown>
		...
   1027d: 00           	<unknown>
   1027e: 00           	<unknown>
   1027f: 00           	<unknown>
Jessicas-MacBook-Pro:morello-defsym Jess% morello-llvm llvm-readelf -Ws foo  

Symbol table '.dynsym' contains 1 entries:
   Num:    Value          Size Type    Bind   Vis       Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND 

Symbol table '.symtab' contains 5 entries:
   Num:    Value          Size Type    Bind   Vis       Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND 
     1: 0000000000010260     0 NOTYPE  LOCAL  DEFAULT     6 $c.0
     2: 0000000000020280   144 NOTYPE  LOCAL  HIDDEN      7 _DYNAMIC
     3: 0000000000010261     7 FUNC    GLOBAL DEFAULT     6 foo
     4: 0000000000010261     0 NOTYPE  GLOBAL DEFAULT     6 bar

The fact that it's STT_NOTYPE (and size 0) rather than inheriting it from the symbol it's being set to an alias of is a bit sad (can't do much about the absolute address case, but in this case we could, though awkward questions arise when you ask what foo-N should put for size, and even foo+N you can't quite express what you really want in the symbol table, which is to have base foo, offset N and length the same as foo's so you'd have to approximate it by foo.len - N and hope nobody tries to access before the start) and a (CHERI-LLVM) upstream deficiency (though in practice, who actually does things like that...), but llvm-objdump should be able to cope with that input and not do clearly-wrong things like try to disassemble from an odd address.

Edited Oct 05, 2021 by Jessica Clarke
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking